From: Mike Bayer Date: Sun, 30 Sep 2012 16:43:00 +0000 (-0400) Subject: Merged in BryceLohr/alembic (pull request #14) X-Git-Tag: rel_0_4_0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9399eb21c3396a9d6c631997d09438012f96c19c;p=thirdparty%2Fsqlalchemy%2Falembic.git Merged in BryceLohr/alembic (pull request #14) --- 9399eb21c3396a9d6c631997d09438012f96c19c diff --cc alembic/command.py index 163c92cf,67b0d668..75e3aa80 --- a/alembic/command.py +++ b/alembic/command.py @@@ -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"): diff --cc alembic/migration.py index 27e771df,76699062..9bfcaebf --- a/alembic/migration.py +++ b/alembic/migration.py @@@ -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. diff --cc alembic/templates/multidb/env.py index 7097dabd,d3ccc553..90bc0dbd --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@@ -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