![Stephen Finucane](/assets/img/avatar_default.png)
This looks more complicated than it is, but it's really quite simple. Essentially we have to deal with two possible configurations: - For existing deployments, the DB sync operation should apply any outstanding sqlalchemy-migrate-based migrations, dummy apply the initial alembic migration, and then apply any additional alembic-based migrations requested (or any available, if no version is specified). - For new deployments, the DB sync operation should apply the initial alembic migration and any additional alembic-based migrations requested (or any available, if no version is specified). No sqlalchemy-migrate-based migrations will ever be applied. While we continue to allow users to request a specific database migration version to upgrade to, we *do not* allow them to request a sqlalchemy-migrate-based migration version. There's no good reason to do this - the deployment won't run with an out-of-date DB schema (something that's also true of the alembic migration, fwiw) - and we want to get people off of sqlalchemy-migrate as fast as possible. A change in a future release can remove the sqlalchemy-migrate-based migrations once we're sure that they'll have upgraded to a release including all of the sqlalchemy-migrated-based migrations (so Wallaby). Tests are modified to validate the sanity of these operations. They're mostly trivial changes, but we do need to do some funky things to ensure that (a) we don't use logger configuration from 'alembic.ini' that will mess with our existing logger configuration and (b) we re-use connection objects as necessary to allow us to run tests against in-memory databases, where a different connection would actually mean a different database. We also can't rely on 'WalkVersionsMixin' from oslo.db since that only supports sqlalchemy-migrate [1]. We instead must re-invent the wheel here somewhat. [1] https://github.com/openstack/oslo.db/blob/10.0.0/oslo_db/sqlalchemy/test_migrations.py#L42-L44 Change-Id: I850af601f81bd5d2ecc029682ae10d3a07c936ce Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
90 lines
2.1 KiB
INI
90 lines
2.1 KiB
INI
# A generic, single database configuration.
|
|
|
|
[alembic]
|
|
# path to migration scripts
|
|
script_location = %(here)s/migrations
|
|
|
|
# template used to generate migration files
|
|
# file_template = %%(rev)s_%%(slug)s
|
|
|
|
# sys.path path, will be prepended to sys.path if present.
|
|
# defaults to the current working directory.
|
|
prepend_sys_path = .
|
|
|
|
# timezone to use when rendering the date
|
|
# within the migration file as well as the filename.
|
|
# string value is passed to dateutil.tz.gettz()
|
|
# leave blank for localtime
|
|
# timezone =
|
|
|
|
# max length of characters to apply to the
|
|
# "slug" field
|
|
# truncate_slug_length = 40
|
|
|
|
# set to 'true' to run the environment during
|
|
# the 'revision' command, regardless of autogenerate
|
|
# revision_environment = false
|
|
|
|
# set to 'true' to allow .pyc and .pyo files without
|
|
# a source .py file to be detected as revisions in the
|
|
# versions/ directory
|
|
# sourceless = false
|
|
|
|
# version location specification; this defaults
|
|
# to migrations/versions. When using multiple version
|
|
# directories, initial revisions must be specified with --version-path
|
|
# version_locations = %(here)s/bar %(here)s/bat migrations/versions
|
|
|
|
# the output encoding used when revision files
|
|
# are written from script.py.mako
|
|
# output_encoding = utf-8
|
|
|
|
sqlalchemy.url = sqlite:///nova_api.db
|
|
|
|
|
|
[post_write_hooks]
|
|
# post_write_hooks defines scripts or Python functions that are run
|
|
# on newly generated revision scripts. See the documentation for further
|
|
# detail and examples
|
|
|
|
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
|
# hooks=black
|
|
# black.type=console_scripts
|
|
# black.entrypoint=black
|
|
# black.options=-l 79
|
|
|
|
# Logging configuration
|
|
[loggers]
|
|
keys = root,sqlalchemy,alembic
|
|
|
|
[handlers]
|
|
keys = console
|
|
|
|
[formatters]
|
|
keys = generic
|
|
|
|
[logger_root]
|
|
level = WARN
|
|
handlers = console
|
|
qualname =
|
|
|
|
[logger_sqlalchemy]
|
|
level = WARN
|
|
handlers =
|
|
qualname = sqlalchemy.engine
|
|
|
|
[logger_alembic]
|
|
level = INFO
|
|
handlers =
|
|
qualname = alembic
|
|
|
|
[handler_console]
|
|
class = StreamHandler
|
|
args = (sys.stderr,)
|
|
level = NOTSET
|
|
formatter = generic
|
|
|
|
[formatter_generic]
|
|
format = %(levelname)-5.5s [%(name)s] %(message)s
|
|
datefmt = %H:%M:%S
|