From 77c01ae80ad3ccf06454c97c1109c29e1f4a9fce Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 15 Jun 2022 12:52:46 +0200 Subject: [PATCH] migration change uuid for system_uuid --- ...3348969a583_system_uuid_instead_of_uuid.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ereuse_devicehub/migrations/versions/73348969a583_system_uuid_instead_of_uuid.py diff --git a/ereuse_devicehub/migrations/versions/73348969a583_system_uuid_instead_of_uuid.py b/ereuse_devicehub/migrations/versions/73348969a583_system_uuid_instead_of_uuid.py new file mode 100644 index 00000000..03441994 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/73348969a583_system_uuid_instead_of_uuid.py @@ -0,0 +1,33 @@ +"""system_uuid instead of uuid + +Revision ID: 73348969a583 +Revises: dac62da1621a +Create Date: 2022-06-15 12:27:23.170313 + +""" +from alembic import context, op + +# revision identifiers, used by Alembic. +revision = '73348969a583' +down_revision = 'dac62da1621a' +branch_labels = None +depends_on = None + + +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + + +def upgrade(): + op.alter_column( + 'computer', 'uuid', new_column_name="system_uuid", schema=f'{get_inv()}' + ) + + +def downgrade(): + op.alter_column( + 'computer', 'system_uuid', new_column_name="uuid", schema=f'{get_inv()}' + )