app/migrations/versions/2020_091020_84471852b610_.py

45 lines
1.5 KiB
Python
Raw Normal View History

2020-09-11 02:15:21 +08:00
"""empty message
Revision ID: 84471852b610
Revises: b82bcad9accf
Create Date: 2020-09-10 20:15:10.956801
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '84471852b610'
down_revision = 'b82bcad9accf'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('batch_import',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('file_id', sa.Integer(), nullable=False),
sa.Column('processed', sa.Boolean(), nullable=False),
sa.Column('summary', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['file_id'], ['file.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.add_column('alias', sa.Column('batch_import_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'alias', 'batch_import', ['batch_import_id'], ['id'], ondelete='SET NULL')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'alias', type_='foreignkey')
op.drop_column('alias', 'batch_import_id')
op.drop_table('batch_import')
# ### end Alembic commands ###