"""timesehets_teams

Revision ID: f56a57f9a7e9
Revises: 4defc9be4de7
Create Date: 2023-06-22 14:44:11.131646

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f56a57f9a7e9'
down_revision = '4defc9be4de7'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_timesheets_team',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('import_original', sa.Boolean(), nullable=True),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('team_type', sa.String(length=32), server_default=sa.text("'independent'"), nullable=False),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.Column('head_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['head_id'], ['cmf_person.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_author_id'), 'cmf_timesheets_team', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_created_at'), 'cmf_timesheets_team', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_deleted'), 'cmf_timesheets_team', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_import_id'), 'cmf_timesheets_team', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_locked_at'), 'cmf_timesheets_team', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_locked_by_id'), 'cmf_timesheets_team', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_modified_at'), 'cmf_timesheets_team', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_modified_by_id'), 'cmf_timesheets_team', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_owner_id'), 'cmf_timesheets_team', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_version'), 'cmf_timesheets_team', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_cmf_viewed_at'), 'cmf_timesheets_team', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_code'), 'cmf_timesheets_team', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_timesheets_team_head_id'), 'cmf_timesheets_team', ['head_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_name'), 'cmf_timesheets_team', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_orderno'), 'cmf_timesheets_team', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_parent_id'), 'cmf_timesheets_team', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_perm_acl_id'), 'cmf_timesheets_team', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_perm_parent_id'), 'cmf_timesheets_team', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_root_parent_id'), 'cmf_timesheets_team', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_tree_parent_id'), 'cmf_timesheets_team', ['tree_parent_id'], unique=False)
    op.create_table('cmf_timesheets_team_member',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('import_original', sa.Boolean(), nullable=True),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('share_part', sa.Integer(), server_default='100', nullable=False),
    sa.Column('date_start', sa.DATE(), nullable=True),
    sa.Column('date_end', sa.DATE(), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=False),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.Column('role_id', sa.String(length=64), nullable=True),
    sa.Column('person_id', sa.String(length=64), nullable=False),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['cmf_timesheets_team.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['cmf_person.id'], ),
    sa.ForeignKeyConstraint(['role_id'], ['cmf_role.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_author_id'), 'cmf_timesheets_team_member', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_created_at'), 'cmf_timesheets_team_member', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_deleted'), 'cmf_timesheets_team_member', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_import_id'), 'cmf_timesheets_team_member', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_locked_at'), 'cmf_timesheets_team_member', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_locked_by_id'), 'cmf_timesheets_team_member', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_modified_at'), 'cmf_timesheets_team_member', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_modified_by_id'), 'cmf_timesheets_team_member', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_owner_id'), 'cmf_timesheets_team_member', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_version'), 'cmf_timesheets_team_member', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_cmf_viewed_at'), 'cmf_timesheets_team_member', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_code'), 'cmf_timesheets_team_member', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_timesheets_team_member_name'), 'cmf_timesheets_team_member', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_orderno'), 'cmf_timesheets_team_member', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_parent_id'), 'cmf_timesheets_team_member', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_perm_acl_id'), 'cmf_timesheets_team_member', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_perm_parent_id'), 'cmf_timesheets_team_member', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_person_id'), 'cmf_timesheets_team_member', ['person_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_role_id'), 'cmf_timesheets_team_member', ['role_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_root_parent_id'), 'cmf_timesheets_team_member', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_member_tree_parent_id'), 'cmf_timesheets_team_member', ['tree_parent_id'], unique=False)
    op.create_table('cmf_timesheets_team_members',
    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.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_timesheets_team_members_left_id'), 'cmf_timesheets_team_members', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_members_parent_id'), 'cmf_timesheets_team_members', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_members_right_id'), 'cmf_timesheets_team_members', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_members_root_id'), 'cmf_timesheets_team_members', ['root_id'], unique=False)
    op.create_table('cmf_timesheets_team_projects',
    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.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_timesheets_team_projects_left_id'), 'cmf_timesheets_team_projects', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_projects_parent_id'), 'cmf_timesheets_team_projects', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_projects_right_id'), 'cmf_timesheets_team_projects', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_timesheets_team_projects_root_id'), 'cmf_timesheets_team_projects', ['root_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_timesheets_team_projects_root_id'), table_name='cmf_timesheets_team_projects')
    op.drop_index(op.f('ix_cmf_timesheets_team_projects_right_id'), table_name='cmf_timesheets_team_projects')
    op.drop_index(op.f('ix_cmf_timesheets_team_projects_parent_id'), table_name='cmf_timesheets_team_projects')
    op.drop_index(op.f('ix_cmf_timesheets_team_projects_left_id'), table_name='cmf_timesheets_team_projects')
    op.drop_table('cmf_timesheets_team_projects')
    op.drop_index(op.f('ix_cmf_timesheets_team_members_root_id'), table_name='cmf_timesheets_team_members')
    op.drop_index(op.f('ix_cmf_timesheets_team_members_right_id'), table_name='cmf_timesheets_team_members')
    op.drop_index(op.f('ix_cmf_timesheets_team_members_parent_id'), table_name='cmf_timesheets_team_members')
    op.drop_index(op.f('ix_cmf_timesheets_team_members_left_id'), table_name='cmf_timesheets_team_members')
    op.drop_table('cmf_timesheets_team_members')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_tree_parent_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_root_parent_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_role_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_person_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_perm_parent_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_perm_acl_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_parent_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_orderno'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_name'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_code'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_viewed_at'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_version'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_owner_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_modified_by_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_modified_at'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_locked_by_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_locked_at'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_import_id'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_deleted'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_created_at'), table_name='cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_member_cmf_author_id'), table_name='cmf_timesheets_team_member')
    op.drop_table('cmf_timesheets_team_member')
    op.drop_index(op.f('ix_cmf_timesheets_team_tree_parent_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_root_parent_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_perm_parent_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_perm_acl_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_parent_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_orderno'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_name'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_head_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_code'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_viewed_at'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_version'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_owner_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_modified_by_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_modified_at'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_locked_by_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_locked_at'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_import_id'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_deleted'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_created_at'), table_name='cmf_timesheets_team')
    op.drop_index(op.f('ix_cmf_timesheets_team_cmf_author_id'), table_name='cmf_timesheets_team')
    op.drop_table('cmf_timesheets_team')
    # ### end Alembic commands ###
