Merge "add engine parameter for offline migrations"
This commit is contained in:
commit
66fcbed75b
@ -414,6 +414,10 @@ admin_password = %SERVICE_PASSWORD%
|
|||||||
# main neutron server. (Leave it as is if the database runs on this host.)
|
# main neutron server. (Leave it as is if the database runs on this host.)
|
||||||
# connection = sqlite://
|
# connection = sqlite://
|
||||||
|
|
||||||
|
# Database engine for which script will be generated when using offline
|
||||||
|
# migration
|
||||||
|
# engine =
|
||||||
|
|
||||||
# The SQLAlchemy connection string used to connect to the slave database
|
# The SQLAlchemy connection string used to connect to the slave database
|
||||||
# slave_connection =
|
# slave_connection =
|
||||||
|
|
||||||
|
@ -48,16 +48,19 @@ target_metadata = model_base.BASEV2.metadata
|
|||||||
def run_migrations_offline():
|
def run_migrations_offline():
|
||||||
"""Run migrations in 'offline' mode.
|
"""Run migrations in 'offline' mode.
|
||||||
|
|
||||||
This configures the context with just a URL
|
This configures the context with either a URL
|
||||||
and not an Engine, though an Engine is acceptable
|
or an Engine.
|
||||||
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
|
Calls to context.execute() here emit the given string to the
|
||||||
script output.
|
script output.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
context.configure(url=neutron_config.database.connection)
|
kwargs = dict()
|
||||||
|
if neutron_config.database.connection:
|
||||||
|
kwargs['url'] = neutron_config.database.connection
|
||||||
|
else:
|
||||||
|
kwargs['dialect_name'] = neutron_config.database.engine
|
||||||
|
context.configure(**kwargs)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
context.run_migrations(active_plugins=active_plugins,
|
context.run_migrations(active_plugins=active_plugins,
|
||||||
|
@ -47,11 +47,14 @@ _db_opts = [
|
|||||||
default='',
|
default='',
|
||||||
secret=True,
|
secret=True,
|
||||||
help=_('URL to database')),
|
help=_('URL to database')),
|
||||||
|
cfg.StrOpt('engine',
|
||||||
|
default='',
|
||||||
|
help=_('Database engine')),
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.ConfigOpts()
|
CONF = cfg.ConfigOpts()
|
||||||
CONF.register_opts(_core_opts)
|
CONF.register_cli_opts(_core_opts)
|
||||||
CONF.register_opts(_db_opts, 'database')
|
CONF.register_cli_opts(_db_opts, 'database')
|
||||||
CONF.register_opts(_quota_opts, 'QUOTAS')
|
CONF.register_opts(_quota_opts, 'QUOTAS')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user