sql migration

This commit is contained in:
Son NK 2020-09-10 20:15:21 +02:00
parent f664243e42
commit b92966b2c6
1 changed files with 44 additions and 0 deletions

View File

@ -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 ###