more robust migrations
This commit is contained in:
@@ -19,22 +19,22 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
if 'message_attachment' not in tables:
|
||||
op.create_table('message_attachment',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('message_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('path', sa.String(length=512), nullable=False),
|
||||
sa.Column('type', sa.String(length=100), nullable=True),
|
||||
sa.Column('size', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('message_id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('path', sa.String(length=512), nullable=False),
|
||||
sa.Column('type', sa.String(length=100), nullable=True),
|
||||
sa.Column('size', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('message', schema=None) as batch_op:
|
||||
batch_op.drop_column('attachment_path')
|
||||
batch_op.drop_column('attachment_type')
|
||||
@@ -55,4 +55,4 @@ def downgrade():
|
||||
batch_op.add_column(sa.Column('attachment_path', sa.VARCHAR(length=512), autoincrement=False, nullable=True))
|
||||
|
||||
op.drop_table('message_attachment')
|
||||
# ### end Alembic commands ###
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user