From 9b1e8617fab7aaf041dbbbc897f0ee7d3a511cd4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 25 Apr 2022 11:43:30 +0200 Subject: [PATCH] add sid in snapshot_errors --- .../6f6771813f2e_change_wbid_for_sid.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ereuse_devicehub/migrations/versions/6f6771813f2e_change_wbid_for_sid.py b/ereuse_devicehub/migrations/versions/6f6771813f2e_change_wbid_for_sid.py index ca4e7212..6debf4dd 100644 --- a/ereuse_devicehub/migrations/versions/6f6771813f2e_change_wbid_for_sid.py +++ b/ereuse_devicehub/migrations/versions/6f6771813f2e_change_wbid_for_sid.py @@ -34,6 +34,15 @@ def upgrade_datas(): where wbid='{wbid}';""" con.execute(sql) + sql = f"select wbid from {get_inv()}.snapshot_errors;" + snapshots = con.execute(sql) + for snap in snapshots: + wbid = snap.wbid + if wbid: + sql = f"""update {get_inv()}.snapshot set sid='{wbid}' + where wbid='{wbid}';""" + con.execute(sql) + def upgrade(): op.add_column( @@ -44,6 +53,16 @@ def upgrade(): upgrade_datas() op.drop_column('snapshot', 'wbid', schema=f'{get_inv()}') + op.add_column( + 'snapshot_errors', + sa.Column('sid', citext.CIText(), nullable=True), + schema=f'{get_inv()}', + ) + upgrade_datas() + op.drop_column('snapshot', 'wbid', schema=f'{get_inv()}') + op.drop_column('snapshot_errors', 'wbid', schema=f'{get_inv()}') + def downgrade(): op.drop_column('snapshot', 'sid', schema=f'{get_inv()}') + op.drop_column('snapshot_errors', 'sid', schema=f'{get_inv()}')