Commits

Mike Bayer  committed e5f8d40

- [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

  • Participants
  • Parent commits 72102ad

Comments (0)

Files changed (4)

   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,

File alembic/command.py

 
     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()
 

File alembic/templates/multidb/env.py

 # 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__)
                         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:

File alembic/templates/multidb/script.py.mako

     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}():