Milimetric has submitted this change and it was merged.
Change subject: Correcting bug on alembic migration script.
......................................................................
Correcting bug on alembic migration script.
Alembic upgrade was upgrading testing db twice rather
testing and development db.
Change-Id: Id51184aa94d6905f6816b5ac201812cce24d2252
---
M database_migrations/env.py
1 file changed, 12 insertions(+), 11 deletions(-)
Approvals:
Milimetric: Looks good to me, approved
jenkins-bot: Verified
diff --git a/database_migrations/env.py b/database_migrations/env.py
index 3a7d41c..faf3967 100644
--- a/database_migrations/env.py
+++ b/database_migrations/env.py
@@ -28,11 +28,11 @@
def get_engine(config):
"""
Create a sqlalchemy engine for a database.
-
+
Returns:
sqlalchemy engine connected to the database.
"""
-
+
return create_engine(
config['WIKIMETRICS_ENGINE_URL'],
echo=config['SQL_ECHO'])
@@ -40,43 +40,44 @@
def run_migrations_offline():
"""Run migrations in 'offline' mode.
-
+
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
-
+
Calls to context.execute() here emit the given string to the
script output.
-
+
"""
url = db.get_engine().url
context.configure(url=url)
-
+
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
-
+
In this scenario we need to create an Engine
and associate a connection with the context.
-
+
"""
- config = db.config
+ import copy
+ config = copy.copy(db.config)
engine = get_engine(config)
test_config = setup_testing_config(config)
test_engine = get_engine(test_config)
test_metadata = db.WikimetricsBase.metadata
-
+
for name, eng, meta_data in [(test_config['WIKIMETRICS_ENGINE_URL'],
test_engine, test_metadata),
(config['WIKIMETRICS_ENGINE_URL'],
engine, target_metadata)]:
connection = eng.connect()
context.configure(connection=connection, target_metadata=meta_data)
-
+
print "Running migration for " + name
try:
with context.begin_transaction():
--
To view, visit https://gerrit.wikimedia.org/r/118689
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id51184aa94d6905f6816b5ac201812cce24d2252
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Nuria <[email protected]>
Gerrit-Reviewer: Milimetric <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits