mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 20:55:10 +01:00
Cleanup and fixed the down migration
This commit is contained in:
@@ -24,21 +24,14 @@ def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('bookmark', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(batch_op.f('bookmark_user'), type_='foreignkey')
|
||||
#batch_op.add_column(sa.Column('user_key', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
|
||||
#batch_op.alter_column(sa.Column('userkey'), new_column_name='user_key')
|
||||
batch_op.alter_column('userkey', new_column_name='user_key')
|
||||
batch_op.create_foreign_key('bookmark_user', 'user', ['user_key'], ['key'])
|
||||
#batch_op.drop_column('userkey')
|
||||
|
||||
with op.batch_alter_table('publictag', schema=None) as batch_op:
|
||||
#batch_op.add_column(sa.Column('tag_key', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
|
||||
#batch_op.add_column(sa.Column('user_key', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
|
||||
batch_op.drop_constraint(batch_op.f('publictag_user'), type_='foreignkey')
|
||||
batch_op.alter_column('userkey', new_column_name='user_key')
|
||||
batch_op.alter_column('tagkey', new_column_name='tag_key')
|
||||
batch_op.create_foreign_key('publictag_user', 'user', ['user_key'], ['key'])
|
||||
#batch_op.drop_column('tagkey')
|
||||
#batch_op.drop_column('userkey')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -47,21 +40,14 @@ def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('publictag', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('userkey', sa.VARCHAR(length=255), nullable=False))
|
||||
batch_op.add_column(sa.Column('tagkey', sa.VARCHAR(length=255), nullable=False))
|
||||
batch_op.drop_constraint(None, type_='foreignkey')
|
||||
batch_op.create_foreign_key(batch_op.f('publictag_user'), 'user', ['userkey'], ['key'])
|
||||
batch_op.alter_column('created_date',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True,
|
||||
existing_server_default=sa.text('(null)'))
|
||||
batch_op.drop_column('user_key')
|
||||
batch_op.drop_column('tag_key')
|
||||
batch_op.drop_constraint(batch_op.f('publictag_user'), type_='foreignkey')
|
||||
batch_op.alter_column('user_key', new_column_name='userkey')
|
||||
batch_op.alter_column('tag_key', new_column_name='tagkey')
|
||||
batch_op.create_foreign_key('publictag_user', 'user', ['userkey'], ['key'])
|
||||
|
||||
with op.batch_alter_table('bookmark', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('userkey', sa.VARCHAR(length=255), nullable=False))
|
||||
batch_op.drop_constraint(None, type_='foreignkey')
|
||||
batch_op.create_foreign_key(batch_op.f('bookmark_user'), 'user', ['userkey'], ['key'])
|
||||
batch_op.drop_column('user_key')
|
||||
batch_op.drop_constraint(batch_op.f('bookmark_user'), type_='foreignkey')
|
||||
batch_op.alter_column('user_key', new_column_name='userkey')
|
||||
batch_op.create_foreign_key('bookmark_user', 'user', ['userkey'], ['key'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user