fix(migration): correct the sequence_number

Signed-off-by: -LAN- <laipz8200@outlook.com>
pull/21228/head
-LAN- 11 months ago
parent 57bff7820f
commit d3213b64bb
No known key found for this signature in database
GPG Key ID: 6BA0D108DED011FF

@ -38,14 +38,15 @@ def downgrade():
connection = op.get_bind() connection = op.get_bind()
connection.execute(sa.text(""" connection.execute(sa.text("""
UPDATE workflow_runs UPDATE workflow_runs
SET sequence_number = ( SET sequence_number = subquery.row_num
SELECT ROW_NUMBER() OVER ( FROM (
SELECT id, ROW_NUMBER() OVER (
PARTITION BY tenant_id, app_id PARTITION BY tenant_id, app_id
ORDER BY created_at, id ORDER BY created_at, id
) ) as row_num
FROM workflow_runs wr2 FROM workflow_runs
WHERE wr2.id = workflow_runs.id ) subquery
) WHERE workflow_runs.id = subquery.id
""")) """))
# Step 3: Make the column NOT NULL and add the index # Step 3: Make the column NOT NULL and add the index

Loading…
Cancel
Save