Skip to content
Corridor V1.26.08 is out, see what's new

Technology

DB Operations

Ask AI

The corridor-api db command for migrating the database schema to the latest version, including the upgrade command and its --no-export flag.

As new versions are released, new tables or columns might be added or there might be some changes in the schema of the tables. To get the database updated with the latest schema, Corridor provides utilities to interact with the database and be up to date with the latest codebase.

The database related commands are only available for corridor-api.

The command with available options:

Terminal window
$ corridor-api db --help
Usage: corridor-api db [OPTIONS] COMMAND [ARGS]...
Perform database migrations.
Options:
--help Show this message and exit.
Commands:
clean Clean the current DB by removing ALL tables
current Display the current revision for each database.
export Export DB data in sqlite format
history List changeset scripts in chronological order.
import Import DB from a previously exported sqlite DB
migrate Create an autogenerated revision file.
revision Create an empty revision file.
stamp Set the revision table without running any migrations
upgrade Upgrade to a later version and also backup the DB

Notes:

  • upgrade: This command allows you to update to the current version, as part of the broader Corridor upgrade process. For example: db upgrade will upgrade to the current version.

    Every time there is an upgrade done an automatic backup of the Database will be taken. The backup will be stored in the directory specified by the environment variable CORRIDOR_CONFIGS.

    If the user want to skip taking a backup, then the —no-export flag could be used. For example: db upgrade --no-export

  • downgrade: This command is not supported anymore and users won’t be able to revert back to a previous version

If let’s say v1.15.0 of corridor is installed, to upgrade the database to v1.15.0 version, from the current database revision (which could be any prior version of corridor - v1.14.x or v1.13.x etc):

Terminal window
$ corridor-api db upgrade
INFO [alembic.migration] Context impl OracleImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
INFO [alembic.migration] Running upgrade 51ff3rd44f2a -> 34d63a3442c6, Add tool-based approval responsibilties
INFO [alembic.migration] Running upgrade 34d63a3442c6 -> 736a26dd93f9, Add first-name and last-name to users