The mogan-dbsync utility is used to create the database schema tables that the mogan services will use for storage. It can also be used to upgrade existing database tables when migrating between different versions of mogan.

The Alembic library is used to perform the database migrations.


This is a partial list of the most useful options. To see the full list, run the following:

mogan-dbsync --help
-h, --help

Show help message and exit.

--config-dir <DIR>

Path to a config directory with configuration files.

--config-file <PATH>

Path to a configuration file to use.

-d, --debug

Print debugging output.


Show the program’s version number and exit.

upgrade, stamp, revision, version, create_schema

The command to run.


Options for the various commands for mogan-dbsync are listed when the -h or --help option is used after the command.

For example:

mogan-dbsync create_schema --help

Information about the database is read from the mogan configuration file used by the API server and conductor services. This file must be specified with the --config-file option:

mogan-dbsync --config-file /path/to/mogan.conf create_schema

The configuration file defines the database backend to use with the connection database option:


If no configuration file is specified with the --config-file option, mogan-dbsync assumes an SQLite database.

Command Options

mogan-dbsync is given a command that tells the utility what actions to perform. These commands can take arguments. Several commands are available:


-h, --help

Show help for create_schema and exit.

This command will create database tables based on the most current version. It assumes that there are no existing tables.

An example of creating database tables with the most recent version:

mogan-dbsync --config-file=/etc/mogan/mogan.conf create_schema


-h, --help

Show help for revision and exit.

-m <MESSAGE>, --message <MESSAGE>

The message to use with the revision file.


Compares table metadata in the application with the status of the database and generates migrations based on this comparison.

This command will create a new revision file. You can use the --message option to comment the revision.

This is really only useful for mogan developers making changes that require database changes. This revision file is used during database migration and will specify the changes that need to be made to the database tables. Further discussion is beyond the scope of this document.


-h, --help

Show help for stamp and exit.

--revision <REVISION>

The revision number.

This command will ‘stamp’ the revision table with the version specified with the --revision option. It will not run any migrations.


-h, --help

Show help for upgrade and exit.

--revision <REVISION>

The revision number to upgrade to.

This command will upgrade existing database tables to the most recent version, or to the version specified with the --revision option.

If there are no existing tables, then new tables are created, beginning with the oldest known version, and successively upgraded using all of the database migration files, until they are at the specified version. Note that this behavior is different from the create_schema command that creates the tables based on the most recent version.

An example of upgrading to the most recent table versions:

mogan-dbsync --config-file=/etc/mogan/mogan.conf upgrade


This command is the default if no command is given to mogan-dbsync.


The upgrade command is not compatible with SQLite databases since it uses ALTER TABLE commands to upgrade the database tables. SQLite supports only a limited subset of ALTER TABLE.


-h, --help

Show help for version and exit.

This command will output the current database version.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.