Skip to content

Commit 4563718

Browse files
committed
fix: expect _pkey constraint name on postgres
1 parent 09ac4e4 commit 4563718

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sc_audit/migrations/versions/52e5e68af772_switch_distributiontx_pk_to_paging_token.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,25 @@ def get_naming_convention():
2828

2929
def upgrade() -> None:
3030
naming_convention = get_naming_convention()
31+
dialect_name = context.get_context().dialect.name
3132

3233
with op.batch_alter_table('distribution_txs', schema=None, naming_convention=naming_convention) as batch_op:
33-
batch_op.drop_constraint(None, type_='primary') # type: ignore
34+
constraint_name = 'distribution_txs_pkey' if dialect_name == 'postgresql' else None
35+
batch_op.drop_constraint(constraint_name, type_='primary') # type: ignore
3436
batch_op.create_primary_key(batch_op.f('pk_distribution_txs'), ['paging_token'])
3537
batch_op.drop_index(batch_op.f('idx_dtx_toid'))
3638
batch_op.create_index('idx_dtx_hash', ['hash'], unique=False)
3739

3840
with op.batch_alter_table('test_distribution_txs', schema=None, naming_convention=naming_convention) as batch_op:
39-
batch_op.drop_constraint(None, type_='primary') # type: ignore
41+
constraint_name = 'test_distribution_txs_pkey' if dialect_name == 'postgresql' else None
42+
batch_op.drop_constraint(constraint_name, type_='primary') # type: ignore
4043
batch_op.create_primary_key(batch_op.f('pk_test_distribution_txs'), ['paging_token'])
4144

4245

4346
def downgrade() -> None:
47+
"""
48+
Downgrade will fail if there are multiple outflows with the same tx hash.
49+
"""
4450
naming_convention = get_naming_convention()
4551

4652
with op.batch_alter_table('distribution_txs', schema=None, naming_convention=naming_convention) as batch_op:

0 commit comments

Comments
 (0)