From dbbab28844d1c114a7369a83b8925f5dade153f5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 29 Dec 2020 20:39:04 +0100 Subject: [PATCH] adding migration --- .../versions/b4bd1538bad5_update_live.py | 44 +++++++++++++++++++ ereuse_devicehub/resources/enums.py | 1 + 2 files changed, 45 insertions(+) create mode 100644 ereuse_devicehub/migrations/versions/b4bd1538bad5_update_live.py diff --git a/ereuse_devicehub/migrations/versions/b4bd1538bad5_update_live.py b/ereuse_devicehub/migrations/versions/b4bd1538bad5_update_live.py new file mode 100644 index 00000000..e81b59c1 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/b4bd1538bad5_update_live.py @@ -0,0 +1,44 @@ +"""update_live + +Revision ID: b4bd1538bad5 +Revises: 3eb50297c365 +Create Date: 2020-12-29 20:19:46.981207 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +import citext +import teal + + +# revision identifiers, used by Alembic. +revision = 'b4bd1538bad5' +down_revision = '3eb50297c365' +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(): + # Live action + op.add_column('device', + sa.Column('software_version', teal.db.StrictVersionType(length=32), nullable=False), + sa.Column('licence_version', teal.db.StrictVersionType(length=32), nullable=False), + sa.Column('software', sa.Enum('Workbench', 'WorkbenchAndroid', 'AndroidApp', 'Web', + 'DesktopApp', 'WorkbenchDesktop', name='snapshotsoftware'), nullable=False), + nullable=True), schema=f'{get_inv()}') + + +def downgrade(): + op.drop_column('device', + sa.Column('software_version', teal.db.StrictVersionType(length=32), nullable=False), + sa.Column('licence_version', teal.db.StrictVersionType(length=32), nullable=False), + sa.Column('software', sa.Enum('Workbench', 'WorkbenchAndroid', 'AndroidApp', 'Web', + 'DesktopApp', 'WorkbenchDesktop', name='snapshotsoftware'), nullable=False), + nullable=True), schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/enums.py b/ereuse_devicehub/resources/enums.py index b9665f8f..a07385d7 100644 --- a/ereuse_devicehub/resources/enums.py +++ b/ereuse_devicehub/resources/enums.py @@ -13,6 +13,7 @@ class SnapshotSoftware(Enum): AndroidApp = 'AndroidApp' Web = 'Web' DesktopApp = 'DesktopApp' + WorkbenchDesktop = 'WorkbenchDesktop' def __str__(self): return self.name