refac
This commit is contained in:
@@ -19,10 +19,17 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
file_cols = {c['name'] for c in inspector.get_columns('file')}
|
||||||
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.add_column('file', sa.Column('hash', sa.Text(), nullable=True))
|
if 'hash' not in file_cols:
|
||||||
op.add_column('file', sa.Column('data', sa.JSON(), nullable=True))
|
op.add_column('file', sa.Column('hash', sa.Text(), nullable=True))
|
||||||
op.add_column('file', sa.Column('updated_at', sa.BigInteger(), nullable=True))
|
if 'data' not in file_cols:
|
||||||
|
op.add_column('file', sa.Column('data', sa.JSON(), nullable=True))
|
||||||
|
if 'updated_at' not in file_cols:
|
||||||
|
op.add_column('file', sa.Column('updated_at', sa.BigInteger(), nullable=True))
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|||||||
@@ -20,8 +20,13 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
file_cols = {c['name'] for c in inspector.get_columns('file')}
|
||||||
|
|
||||||
# 1. Add the `path` column to the "file" table.
|
# 1. Add the `path` column to the "file" table.
|
||||||
op.add_column('file', sa.Column('path', sa.Text(), nullable=True))
|
if 'path' not in file_cols:
|
||||||
|
op.add_column('file', sa.Column('path', sa.Text(), nullable=True))
|
||||||
|
|
||||||
# 2. Convert the `meta` column from Text/JSONField to `JSON()`
|
# 2. Convert the `meta` column from Text/JSONField to `JSON()`
|
||||||
# Use Alembic's default batch_op for dialect compatibility.
|
# Use Alembic's default batch_op for dialect compatibility.
|
||||||
|
|||||||
Reference in New Issue
Block a user