From b92966b2c6434f8fa2dac4b9c368047e8c37022d Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 10 Sep 2020 20:15:21 +0200 Subject: [PATCH] sql migration --- .../versions/2020_091020_84471852b610_.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 migrations/versions/2020_091020_84471852b610_.py diff --git a/migrations/versions/2020_091020_84471852b610_.py b/migrations/versions/2020_091020_84471852b610_.py new file mode 100644 index 00000000..f2acc52b --- /dev/null +++ b/migrations/versions/2020_091020_84471852b610_.py @@ -0,0 +1,44 @@ +"""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 ###