fixing migrations

This commit is contained in:
Cayo Puigdefabregas 2020-12-29 20:55:11 +01:00
parent dbbab28844
commit 1c34ea0074

View file

@ -5,10 +5,10 @@ Revises: 3eb50297c365
Create Date: 2020-12-29 20:19:46.981207
"""
from alembic import context
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import citext
from sqlalchemy.dialects import postgresql
import teal
@ -27,18 +27,31 @@ def get_inv():
def upgrade():
# Live action
op.add_column('device',
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.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()}')
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),
sa.PrimaryKeyConstraint('id'),
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()}')
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()}'
)