From 3cd943037c82873263dab1f7c9fb6f967ee716a1 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 29 Mar 2022 15:44:57 +0200 Subject: [PATCH] add migration for new column --- .../versions/17288b2a7440_add_uuid.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ereuse_devicehub/migrations/versions/17288b2a7440_add_uuid.py diff --git a/ereuse_devicehub/migrations/versions/17288b2a7440_add_uuid.py b/ereuse_devicehub/migrations/versions/17288b2a7440_add_uuid.py new file mode 100644 index 00000000..a6506cf9 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/17288b2a7440_add_uuid.py @@ -0,0 +1,35 @@ +"""change firewire + +Revision ID: 17288b2a7440 +Revises: 8571fb32c912 +Create Date: 2022-03-29 11:49:39.270791 + +""" +import sqlalchemy as sa +from alembic import context, op +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '17288b2a7440' +down_revision = '8571fb32c912' +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.add_column( + 'computer', + sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=True), + schema=f'{get_inv()}', + ) + + +def downgrade(): + op.drop_column('computer', 'uuid', schema=f'{get_inv()}')