"""add CmfAuthHistory model

Revision ID: 8848fba87f0a
Revises: ceed9e1fa31c
Create Date: 2023-10-11 14:29:51.599090

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '8848fba87f0a'
down_revision = 'ceed9e1fa31c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_auth_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('pass_hash', sa.String(length=256), 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.ForeignKeyConstraint(['parent_id'], ['cmf_auth.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_auth_history_cmf_author_id'), 'cmf_auth_history', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_created_at'), 'cmf_auth_history', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_deleted'), 'cmf_auth_history', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_locked_at'), 'cmf_auth_history', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_locked_by_id'), 'cmf_auth_history', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_modified_at'), 'cmf_auth_history', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_modified_by_id'), 'cmf_auth_history', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_owner_id'), 'cmf_auth_history', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_version'), 'cmf_auth_history', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_cmf_viewed_at'), 'cmf_auth_history', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_history_parent_id'), 'cmf_auth_history', ['parent_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_auth_history_parent_id'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_viewed_at'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_version'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_owner_id'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_modified_by_id'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_modified_at'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_locked_by_id'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_locked_at'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_deleted'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_created_at'), table_name='cmf_auth_history')
    op.drop_index(op.f('ix_cmf_auth_history_cmf_author_id'), table_name='cmf_auth_history')
    op.drop_table('cmf_auth_history')
    # ### end Alembic commands ###
