2020-12-29 19:39:04 +00:00
|
|
|
"""update_live
|
|
|
|
|
|
|
|
Revision ID: b4bd1538bad5
|
|
|
|
Revises: 3eb50297c365
|
|
|
|
Create Date: 2020-12-29 20:19:46.981207
|
|
|
|
|
|
|
|
"""
|
2020-12-29 19:55:11 +00:00
|
|
|
from alembic import context
|
2020-12-29 19:39:04 +00:00
|
|
|
from alembic import op
|
|
|
|
import sqlalchemy as sa
|
2020-12-29 19:55:11 +00:00
|
|
|
from sqlalchemy.dialects import postgresql
|
2020-12-29 19:39:04 +00:00
|
|
|
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
|
2020-12-29 19:55:11 +00:00
|
|
|
op.drop_table('live', schema=f'{get_inv()}')
|
|
|
|
op.create_table('live',
|
|
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
|
|
sa.Column('serial_number', sa.Unicode(), nullable=True,
|
|
|
|
comment='The serial number of the Hard Disk in lower case.'),
|
|
|
|
sa.Column('usage_time_hdd', sa.Interval(), nullable=True),
|
|
|
|
sa.Column('snapshot_uuid', postgresql.UUID(as_uuid=True), nullable=False),
|
2020-12-29 19:39:04 +00:00
|
|
|
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),
|
2020-12-29 19:55:11 +00:00
|
|
|
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),
|
|
|
|
sa.PrimaryKeyConstraint('id'),
|
|
|
|
schema=f'{get_inv()}'
|
|
|
|
)
|
2020-12-29 19:39:04 +00:00
|
|
|
|
|
|
|
def downgrade():
|
2020-12-29 19:55:11 +00:00
|
|
|
op.drop_table('live', schema=f'{get_inv()}')
|
|
|
|
op.create_table('live',
|
|
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
|
|
|
sa.Column('serial_number', sa.Unicode(), nullable=True,
|
|
|
|
comment='The serial number of the Hard Disk in lower case.'),
|
|
|
|
sa.Column('usage_time_hdd', sa.Interval(), nullable=True),
|
|
|
|
sa.Column('snapshot_uuid', postgresql.UUID(as_uuid=True), nullable=False),
|
|
|
|
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),
|
|
|
|
sa.PrimaryKeyConstraint('id'),
|
|
|
|
schema=f'{get_inv()}'
|
|
|
|
)
|