Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally migrate database at service startup
In some use cases, notably testing, it can be handy to do database migrations when the web service starts up. This changes adds that functionality, controlled by a [placement_database]/sync_on_startup option that defaults to False. When True, `migration.upgrade('head')` will be called before the placement application is made available to the wsgi server. Alembic protects us against concurrency issues and prevents re-doing already done migrations. This means that it is possible, with the help of oslo.config>=6.7.0 to do something like this: OS_PLACEMENT_DATABASE__CONNECTION=sqlite:// \ OS_PLACEMENT_DATABASE__SYNC_ON_STARTUP=True \ OS_API__AUTH_STRATEGY=noauth2 \ .tox/py36/bin/placement-api and have a ready to go placement api using an in-RAM sql database. A reno is added. Change-Id: Ie43a69be8b75250d9deca6a911eda7b722ef8648
- Loading branch information
Showing
5 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
features: | ||
- | | ||
A configuration setting ``[placement_database]/sync_on_startup`` is added | ||
which, if set to ``True``, will cause database schema migrations to be | ||
called when the placement web application is started. This avoids the need | ||
to call ``placement-manage db sync`` separately. | ||
To preserve backwards compatbility and avoid unexpected changes, the | ||
default of the setting is ``False``. |