]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] Fixed the "multidb" template which was badly out
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:57:29 +0000 (12:57 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:57:29 +0000 (12:57 -0400)
  of date.   It now generates revision files using
  the configuration to determine the different
  upgrade_<xyz>() methods needed as well, instead of
  needing to hardcode these.  Huge thanks to
  BryceLohr for doing the heavy lifting here.  #71

CHANGES
alembic/command.py
alembic/templates/multidb/env.py
alembic/templates/multidb/script.py.mako

diff --git a/CHANGES b/CHANGES
index 3ee614e5148af1bafc6a45748e87d0aa6b0d4cae..598c9695d71c20e232fd669b2a9f47e52b2a3be0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,13 @@
   front-ends can re-use the argument parsing built
   in.  #70
 
+- [bug] Fixed the "multidb" template which was badly out
+  of date.   It now generates revision files using
+  the configuration to determine the different
+  upgrade_<xyz>() methods needed as well, instead of
+  needing to hardcode these.  Huge thanks to
+  BryceLohr for doing the heavy lifting here.  #71
+
 - [bug] Fixed the regexp that was checking for .py files
   in the version directory to allow any .py file through.
   Previously it was doing some kind of defensive checking,
index 75e3aa80e69b49ecb8769d7a677bea3e1921c8f9..c6bc3dc4ba9b7a2467d9aa9320ed9062d2f797d4 100644 (file)
@@ -65,7 +65,8 @@ def revision(config, message=None, autogenerate=False, sql=False):
 
     script = ScriptDirectory.from_config(config)
     template_args = {
-        'config': config # Let templates use config for e.g. multiple databases
+        'config': config  # Let templates use config for
+                          # e.g. multiple databases
     }
     imports = set()
 
index 90bc0dbd875501ca1618a1aa4d194d03a89d365e..76f39824c8bbec6d530994fd170ebcfb7ed002fc 100644 (file)
@@ -11,7 +11,7 @@ USE_TWOPHASE = False
 # access to the values within the .ini file in use.
 config = context.config
 
-# Interpret the config file for Python logging. 
+# Interpret the config file for Python logging.
 # This line sets up loggers basically.
 fileConfig(config.config_file_name)
 logger = logging.getLogger(__name__)
@@ -108,7 +108,6 @@ def run_migrations_online():
                         downgrade_token="%s_downgrades",
                         target_metadata=target_metadata.get(name)
                     )
-            context.execute("-- running migrations for database %s" % name)
             context.run_migrations(engine_name=name)
 
         if USE_TWOPHASE:
index 582492bb7f99e5427922c77222353a2fd699ab81..1e7f79a4b08135b232c30d7c9b8b34e3ac20bb17 100644 (file)
@@ -25,9 +25,12 @@ def downgrade(engine_name):
     eval("downgrade_%s" % engine_name)()
 
 <%
-    db_names = context.get("config").get_main_option("databases")
+    db_names = config.get_main_option("databases")
 %>
 
+## generate an "upgrade_<xyz>() / downgrade_<xyz>()" function
+## for each database name in the ini file.
+
 % for db_name in re.split(r',\s*', db_names):
 
 def upgrade_${db_name}():