Migrate the Identity Service databaseBetween revisions of the Identity Service project, you might
need to complete SQL migrations. The Identity Service project
uses SQLAlchemy-migrate (see http://code.google.com/p/sqlalchemy-migrate/) to
migrate the SQL database between revisions. For core
components, the source code stores migrations in a central
repository under a
keystone/common/sql/migrate_repo
directory.Extensions to the Identity Service might also require SQL
migrations. The directory
keystone/contrib/example in the
keystone repository contains a sample extension
migration.To set up a migration for an extensionCreate a directory structure where
my_extension is the name of the
extension, as follows:
keystone/contrib/my_extension/migrate_repo/versions/.Create empty __init__.py files
in the migrate_repo and
versions
subdirectories.Create a migrate.cfg
configuration file in the
migrate_repo subdirectory,
which conforms to a key/value .ini file format.An example configuration file:[db_settings]
repository_id=my_extension
version_table=migrate_version
required_dbs=[]To test a migration for a specific extensionYou can use the keystone-manage
command with the --extension parameter
for both the db_sync and
db_version commands. Ensure that the
required configuration files exist before completing these
steps.Test your migrations with an example
extension:#bin/keystone-manage db_sync --extension exampleMigrate to version 1:#bin/keystone-manage db_sync --extension example 1Migrate back to version 0:#bin/keystone-manage db_sync --extension example 0Check the version:#bin/keystone-manage db_version --extension example