Skip to content

Commit 50cdcdb

Browse files
committed
[AIRFLOW-2574] Cope with '%' in SQLA DSN when running migrations (#3787)
Alembic uses a ConfigParser like Airflow does, and "%% is a special value in there, so we need to escape it. As per the Alembic docs: > Note that this value is passed to ConfigParser.set, which supports > variable interpolation using pyformat (e.g. `%(some_value)s`). A raw > percent sign not part of an interpolation symbol must therefore be > escaped, e.g. `%%`
1 parent a59bbbf commit 50cdcdb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

airflow/utils/db.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ def upgradedb():
341341
package_dir = os.path.normpath(os.path.join(current_dir, '..'))
342342
directory = os.path.join(package_dir, 'migrations')
343343
config = Config(os.path.join(package_dir, 'alembic.ini'))
344-
config.set_main_option('script_location', directory)
345-
config.set_main_option('sqlalchemy.url', settings.SQL_ALCHEMY_CONN)
344+
config.set_main_option('script_location', directory.replace('%', '%%'))
345+
config.set_main_option('sqlalchemy.url', settings.SQL_ALCHEMY_CONN.replace('%', '%%'))
346346
command.upgrade(config, 'heads')
347347

348348

0 commit comments

Comments
 (0)