"""status_history

Revision ID: 8198421bdbd6
Revises: dd906caccf17
Create Date: 2023-09-13 17:48:55.751772

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8198421bdbd6'
down_revision = 'dd906caccf17'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_status_history',
    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('obj_code', sa.String(length=64), nullable=True),
    sa.Column('from_status_code', sa.String(length=64), nullable=True),
    sa.Column('from_status_name', sa.String(length=256), nullable=True),
    sa.Column('from_status_type', sa.String(length=32), nullable=True),
    sa.Column('to_status_code', sa.String(length=64), nullable=True),
    sa.Column('to_status_name', sa.String(length=256), nullable=True),
    sa.Column('to_status_type', sa.String(length=32), 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=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('obj_id', sa.String(length=64), nullable=False),
    sa.Column('from_status_id', sa.String(length=64), nullable=True),
    sa.Column('to_status_id', sa.String(length=64), nullable=True),
    sa.Column('transition_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['from_status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['to_status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['transition_id'], ['cmf_trans.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_status_history_cmf_author_id'), 'cmf_status_history', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_created_at'), 'cmf_status_history', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_deleted'), 'cmf_status_history', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_locked_at'), 'cmf_status_history', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_locked_by_id'), 'cmf_status_history', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_modified_at'), 'cmf_status_history', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_modified_by_id'), 'cmf_status_history', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_owner_id'), 'cmf_status_history', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_version'), 'cmf_status_history', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_cmf_viewed_at'), 'cmf_status_history', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_from_status_id'), 'cmf_status_history', ['from_status_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_obj_id'), 'cmf_status_history', ['obj_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_parent_id'), 'cmf_status_history', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_to_status_id'), 'cmf_status_history', ['to_status_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_history_transition_id'), 'cmf_status_history', ['transition_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_status_history_transition_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_to_status_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_parent_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_obj_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_from_status_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_viewed_at'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_version'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_owner_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_modified_by_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_modified_at'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_locked_by_id'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_locked_at'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_deleted'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_created_at'), table_name='cmf_status_history')
    op.drop_index(op.f('ix_cmf_status_history_cmf_author_id'), table_name='cmf_status_history')
    op.drop_table('cmf_status_history')
    # ### end Alembic commands ###
