API - fix record_types enum update in migration - fix #230

This commit is contained in:
Sam 2022-09-13 18:58:53 +02:00
parent f38f616145
commit 5e0ebd6e6e

View File

@ -17,11 +17,17 @@ depends_on = None
def upgrade(): def upgrade():
# workaround for PostgreSQL<12
# (can not use ALTER TYPE to add values in migrations)
op.execute("ALTER TYPE record_types RENAME TO record_types_old")
op.execute("CREATE TYPE record_types AS ENUM('AS', 'FD', 'LD', 'MS', 'HA')")
op.execute( op.execute(
""" """
ALTER TYPE record_types ADD VALUE 'HA'; ALTER TABLE records ALTER COLUMN record_type TYPE record_types
USING record_type::text::record_types
""" """
) )
op.execute("DROP TYPE record_types_old")
op.add_column( op.add_column(
'users', sa.Column('display_ascent', sa.Boolean(), nullable=True) 'users', sa.Column('display_ascent', sa.Boolean(), nullable=True)