additional message #348

This commit is contained in:
rimu 2024-11-15 15:51:17 +13:00
parent bf9c849467
commit 3ca073779e

View file

@ -44,6 +44,8 @@ def upgrade():
new_id = users[0].id new_id = users[0].id
old_ids = [user.id for user in users[1:]] old_ids = [user.id for user in users[1:]]
print(profile_id)
if old_ids: if old_ids:
# Update tables with batch IN clause # Update tables with batch IN clause
conn.execute(text('UPDATE "post" SET user_id = :new_id WHERE user_id IN :old_ids'), {"new_id": new_id, "old_ids": tuple(old_ids)}) conn.execute(text('UPDATE "post" SET user_id = :new_id WHERE user_id IN :old_ids'), {"new_id": new_id, "old_ids": tuple(old_ids)})
@ -81,6 +83,7 @@ def upgrade():
# Finalize by dropping and recreating the unique index on ap_profile_id # Finalize by dropping and recreating the unique index on ap_profile_id
with op.batch_alter_table('user', schema=None) as batch_op: with op.batch_alter_table('user', schema=None) as batch_op:
print('Adding unique index...')
batch_op.drop_index('ix_user_ap_profile_id') batch_op.drop_index('ix_user_ap_profile_id')
batch_op.create_index(batch_op.f('ix_user_ap_profile_id'), ['ap_profile_id'], unique=True) batch_op.create_index(batch_op.f('ix_user_ap_profile_id'), ['ap_profile_id'], unique=True)