From b571b2643382c5ef7482e10b70a73e496c1c91ef Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 25 May 2023 10:57:40 +0200 Subject: [PATCH] upgrade datawipe to erasedatawipe --- .../5169765e2653_add_new_erase_data_wipe.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ereuse_devicehub/migrations/versions/5169765e2653_add_new_erase_data_wipe.py b/ereuse_devicehub/migrations/versions/5169765e2653_add_new_erase_data_wipe.py index 1621a547..87c7c6f0 100644 --- a/ereuse_devicehub/migrations/versions/5169765e2653_add_new_erase_data_wipe.py +++ b/ereuse_devicehub/migrations/versions/5169765e2653_add_new_erase_data_wipe.py @@ -23,6 +23,32 @@ def get_inv(): return INV +def upgrade_data(): + con = op.get_bind() + + sql = f"select * from {get_inv()}.data_wipe;" + for d in con.execute(sql): + document_id = d.document_id + author_id = d.author_id + name = d.name + device_id = d.device_id + description = d.description + start_time = d.start_time + end_time = d.end_time + severity = d.severity + + sql = f"""insert into {get_inv()}.erase_data_wipe + (name, description, start_time, end_time, severity, device_id, + author_id, document_id) + values + ({name}, {description}, {start_time}, {end_time}, {severity}, + {device_id}, {author_id}, {document_id}); + """ + con.execute(sql) + + con.execute(sql) + + def upgrade(): op.create_table( 'erase_data_wipe',