Fix #279. Update existing enum

This commit is contained in:
Santiago L 2022-05-24 14:08:23 +02:00
parent e081310069
commit c2bff5dd92
2 changed files with 18 additions and 14 deletions

View File

@ -148,7 +148,6 @@ def upgrade():
name='currency',
create_type=False,
checkfirst=True,
schema=f'{get_inv()}',
)
op.drop_table('trade', schema=f'{get_inv()}')

View File

@ -25,6 +25,20 @@ def get_inv():
def upgrade():
# op.execute("COMMIT")
op.execute("ALTER TYPE snapshotsoftware ADD VALUE 'WorkbenchDesktop'")
SOFTWARE = sa.Enum(
'Workbench',
'WorkbenchAndroid',
'AndroidApp',
'Web',
'DesktopApp',
'WorkbenchDesktop',
name='snapshotsoftware',
create_type=False,
checkfirst=True,
)
# Live action
op.drop_table('live', schema=f'{get_inv()}')
op.create_table(
@ -44,19 +58,7 @@ def upgrade():
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,
),
sa.Column('software', SOFTWARE, nullable=False),
sa.ForeignKeyConstraint(
['id'],
[f'{get_inv()}.action.id'],
@ -86,3 +88,6 @@ def downgrade():
sa.PrimaryKeyConstraint('id'),
schema=f'{get_inv()}',
)
op.execute(
"select e.enumlabel FROM pg_enum e JOIN pg_type t ON e.enumtypid = t.oid WHERE t.typname = 'snapshotsoftware'"
)