]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Merged in BryceLohr/alembic (pull request #14)
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:43:00 +0000 (12:43 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:43:00 +0000 (12:43 -0400)
1  2 
alembic/command.py
alembic/migration.py
alembic/templates/multidb/env.py

index 163c92cfdc1f3c713fdc1982eae89f46b0590341,67b0d668bac736dce1e966e00d5c5177ade33f6e..75e3aa80e69b49ecb8769d7a677bea3e1921c8f9
@@@ -64,15 -63,11 +64,17 @@@ def revision(config, message=None, auto
      """Create a new revision file."""
  
      script = ScriptDirectory.from_config(config)
-     template_args = {}
+     template_args = {
+         'config': config # Let templates use config for e.g. multiple databases
+     }
      imports = set()
 +
 +    environment = util.asbool(
 +        config.get_main_option("revision_environment")
 +    )
 +
      if autogenerate:
 +        environment = True
          util.requires_07("autogenerate")
          def retrieve_migrations(rev, context):
              if script.get_revision(rev) is not script.get_revision("head"):
index 27e771dfef40c3f575339daf5307857e8b004603,76699062a6c9c2ae813a9eb30c6e9300ec4c09af..9bfcaebf086dc79481749b8ad7a6bda2c0ae884d
@@@ -220,11 -220,11 +220,11 @@@ class MigrationContext(object)
              if self.as_sql and not rev:
                  self._version.drop(self.connection)
  
-     def execute(self, sql):
+     def execute(self, sql, execution_options=None):
          """Execute a SQL construct or string statement.
 -        
 +
          The underlying execution mechanics are used, that is
 -        if this is "offline mode" the SQL is written to the 
 +        if this is "offline mode" the SQL is written to the
          output buffer, otherwise the SQL is emitted on
          the current SQLAlchemy connection.
  
index 7097dabdca09ea562dcd58ff323ebbe9a8456633,d3ccc5536a6467ab90481d06b34c03e78f9ae794..90bc0dbd875501ca1618a1aa4d194d03a89d365e
@@@ -1,22 -1,30 +1,30 @@@
- USE_TWOPHASE = False
+ from __future__ import with_statement
  from alembic import context
  from sqlalchemy import engine_from_config, pool
+ from logging.config import fileConfig
+ import logging
  import re
- import sys
  
- import logging
- logging.fileConfig(options.config_file)
+ USE_TWOPHASE = False
+ # this is the Alembic Config object, which provides
+ # access to the values within the .ini file in use.
+ config = context.config
+ # Interpret the config file for Python logging. 
+ # This line sets up loggers basically.
+ fileConfig(config.config_file_name)
+ logger = logging.getLogger(__name__)
  
 -# gather section names referring to different 
 +# gather section names referring to different
  # databases.  These are named "engine1", "engine2"
  # in the sample .ini file.
- db_names = options.get_main_option('databases')
+ db_names = config.get_main_option('databases')
  
  # add your model's MetaData objects here
 -# for 'autogenerate' support.  These must be set 
 -# up to hold just those tables targeting a 
 -# particular database. table.tometadata() may be 
 +# for 'autogenerate' support.  These must be set
 +# up to hold just those tables targeting a
 +# particular database. table.tometadata() may be
  # helpful here in case a "copy" of
  # a MetaData is needed.
  # from myapp import mymodel