Fix eb68f277ab61_add_func_column_to_dynamic_challenges migration (#2374)

* Fix issue in migration with some MySQL versions
This commit is contained in:
Kevin Chung
2023-07-24 00:28:30 -04:00
committed by GitHub
parent 100eb58ac5
commit c2a13e55a7

View File

@@ -19,9 +19,15 @@ def upgrade(op=None):
"dynamic_challenge", sa.Column("function", sa.String(length=32), nullable=True)
)
conn = op.get_bind()
url = str(conn.engine.url)
if url.startswith("postgres"):
conn.execute(
"UPDATE dynamic_challenge SET function = 'logarithmic' WHERE function IS NULL"
)
else:
conn.execute(
"UPDATE dynamic_challenge SET `function` = 'logarithmic' WHERE `function` IS NULL"
)
def downgrade(op=None):