"""git integration

Revision ID: e1bec3e4130e
Revises: a9996241ad5b
Create Date: 2022-11-22 12:43:33.951169

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e1bec3e4130e'
down_revision = 'a9996241ad5b'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_task_cmf_git_branch',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_git_branch.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_task_cmf_git_branch_left_id'), 'cmf_task_cmf_git_branch', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_branch_parent_id'), 'cmf_task_cmf_git_branch', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_branch_right_id'), 'cmf_task_cmf_git_branch', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_branch_root_id'), 'cmf_task_cmf_git_branch', ['root_id'], unique=False)
    op.create_table('cmf_task_cmf_git_commit',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_git_commit.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_task_cmf_git_commit_left_id'), 'cmf_task_cmf_git_commit', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_commit_parent_id'), 'cmf_task_cmf_git_commit', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_commit_right_id'), 'cmf_task_cmf_git_commit', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_commit_root_id'), 'cmf_task_cmf_git_commit', ['root_id'], unique=False)
    op.create_table('cmf_task_cmf_git_merge_request',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_git_merge_request.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_task_cmf_git_merge_request_left_id'), 'cmf_task_cmf_git_merge_request', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_merge_request_parent_id'), 'cmf_task_cmf_git_merge_request', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_merge_request_right_id'), 'cmf_task_cmf_git_merge_request', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_merge_request_root_id'), 'cmf_task_cmf_git_merge_request', ['root_id'], unique=False)
    op.create_table('cmf_task_cmf_git_repo',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_git_repo.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_task_cmf_git_repo_left_id'), 'cmf_task_cmf_git_repo', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_repo_parent_id'), 'cmf_task_cmf_git_repo', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_repo_right_id'), 'cmf_task_cmf_git_repo', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_cmf_git_repo_root_id'), 'cmf_task_cmf_git_repo', ['root_id'], unique=False)
    op.add_column('cmf_git_branch', sa.Column('deleted', sa.Boolean(), nullable=True))
    op.add_column('cmf_git_merge_request', sa.Column('deleted', sa.Boolean(), nullable=True))
    op.add_column('cmf_git_repo', sa.Column('sync', sa.Boolean(), nullable=True))
    op.add_column('cmf_git_repo', sa.Column('last_sync', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_git_repo', sa.Column('deleted', sa.Boolean(), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('cmf_git_repo', 'deleted')
    op.drop_column('cmf_git_repo', 'last_sync')
    op.drop_column('cmf_git_repo', 'sync')
    op.drop_column('cmf_git_merge_request', 'deleted')
    op.drop_column('cmf_git_branch', 'deleted')
    op.drop_index(op.f('ix_cmf_task_cmf_git_repo_root_id'), table_name='cmf_task_cmf_git_repo')
    op.drop_index(op.f('ix_cmf_task_cmf_git_repo_right_id'), table_name='cmf_task_cmf_git_repo')
    op.drop_index(op.f('ix_cmf_task_cmf_git_repo_parent_id'), table_name='cmf_task_cmf_git_repo')
    op.drop_index(op.f('ix_cmf_task_cmf_git_repo_left_id'), table_name='cmf_task_cmf_git_repo')
    op.drop_table('cmf_task_cmf_git_repo')
    op.drop_index(op.f('ix_cmf_task_cmf_git_merge_request_root_id'), table_name='cmf_task_cmf_git_merge_request')
    op.drop_index(op.f('ix_cmf_task_cmf_git_merge_request_right_id'), table_name='cmf_task_cmf_git_merge_request')
    op.drop_index(op.f('ix_cmf_task_cmf_git_merge_request_parent_id'), table_name='cmf_task_cmf_git_merge_request')
    op.drop_index(op.f('ix_cmf_task_cmf_git_merge_request_left_id'), table_name='cmf_task_cmf_git_merge_request')
    op.drop_table('cmf_task_cmf_git_merge_request')
    op.drop_index(op.f('ix_cmf_task_cmf_git_commit_root_id'), table_name='cmf_task_cmf_git_commit')
    op.drop_index(op.f('ix_cmf_task_cmf_git_commit_right_id'), table_name='cmf_task_cmf_git_commit')
    op.drop_index(op.f('ix_cmf_task_cmf_git_commit_parent_id'), table_name='cmf_task_cmf_git_commit')
    op.drop_index(op.f('ix_cmf_task_cmf_git_commit_left_id'), table_name='cmf_task_cmf_git_commit')
    op.drop_table('cmf_task_cmf_git_commit')
    op.drop_index(op.f('ix_cmf_task_cmf_git_branch_root_id'), table_name='cmf_task_cmf_git_branch')
    op.drop_index(op.f('ix_cmf_task_cmf_git_branch_right_id'), table_name='cmf_task_cmf_git_branch')
    op.drop_index(op.f('ix_cmf_task_cmf_git_branch_parent_id'), table_name='cmf_task_cmf_git_branch')
    op.drop_index(op.f('ix_cmf_task_cmf_git_branch_left_id'), table_name='cmf_task_cmf_git_branch')
    op.drop_table('cmf_task_cmf_git_branch')
    # ### end Alembic commands ###
