Page MenuHomePhabricator

Alembic upgrade head should not try to access testing DB when running in production
Closed, ResolvedPublic

Description

Alembic upgrade head should not try to access (wikimetrics_testing) testing DB when running in production.

When debug = false alembic should just be concerned with wikimetric databases.

Please see also bug 64001, which is also alembic related.


Version: unspecified
Severity: normal

Details

Reference
bz64294

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:12 AM
bzimport set Reference to bz64294.

This is already working.

See stdout when executing 'alembic upgrade HEAD' in these 2 cases:

  1. When 'DEBUG = True' in ./wikimetrics/config/db_config.yaml, output is:

INFO [alembic.migration] Context impl MySQLImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
Running migration for wikimetrics
INFO [alembic.migration] Context impl MySQLImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
Running migration for wikimetrics_testing

  1. When 'DEBUG = False' in ./wikimetrics/config/db_config.yaml, output is:

INFO [alembic.migration] Context impl MySQLImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
Running migration for wikimetrics

This code is performing the action (./database_migrations/env.py):

config = db.config
engine = get_engine(config)
migrations = [(engine, target_metadata)]

if db.config['DEBUG'] is True:
    test_config = setup_testing_config(deepcopy(config))
    test_engine = get_engine(test_config)
    test_metadata = db.WikimetricsBase.metadata
    migrations.append((test_engine, test_metadata))

I deduce that nothing more needs to be done for this bug.

The catch is that alembic should not be reading ./wikimetrics/config/db_config.yaml but rather /etc/wikimetrics/db_config.yaml unless this second file is not pressent.

Sorry, this should have been spelled out more clearly.

Change 166762 had a related patch set uploaded by Mforns:
Use /etc/wikimetrics config files for alembic upgrade

https://gerrit.wikimedia.org/r/166762

Change 166762 merged by Milimetric:
Use /etc/wikimetrics config files for alembic upgrade

https://gerrit.wikimedia.org/r/166762