DbShift is a simple database migrations tool with the goal of simplicity. You will be able to create migrations, check the current db status, decide to upgrade or downgrade easily.
This project is deprecated and no longer supported.
Dbshit has been divided into several projects based on Dbshift Core.
go get github.com/limoli/dbshift
-
Create your configuration file and set its path using
DBSHIFT_CONFIG
-
Initialise your configuration:
dbshift init
- Create migration. The following command will create two files
$uuid.down.sql
and$uuid.up.sql
at your migrations folder.
dbshift create my-migration-description
- Check status of your current database.
dbshift status
- Upgrade migrations.
dbshift upgrade
- Downgrade migrations.
dbshift downgrade
- Get list of available upgrade migrations.
dbshift migrations-upgrade
- Get list of available downgrade migrations.
dbshift migrations-downgrade
- Get settings info
dbshift info
- Import missing migrations. It is useful when you work on different initialised databases.
dbshift refresh
- Queries must be database name agnostic
- SRP according to your description
- Write both upgrade and downgrade migrations
All you need is an environment variable DBSHIFT_CONFIG
which represents the path where dbshift will find:
- a configuration file
dbshift.yaml
written by you - an autogenerated lockfile managed from dbshift
export DBSHIFT_CONFIG=/absolutePath/dbshift.yaml
The configuration file has the following structure:
db:
type: mysql
migration:
path: /absolutePath/migrations
pathEnv: "MYSQL_MIGRATIONS_PATH"
connection:
name:
env: MYSQL_DATABASE
value:
user:
env: MYSQL_USER
value:
password:
env: MYSQL_PASSWORD
value:
host:
env: MYSQL_HOST
value:
port:
env: MYSQL_PORT
value: 3306
The connection object is composed by fields which values can be set from the value
field or
from an environment variable declared in the env
field.
The environment variable overrides the value if set.
export MYSQL_DATABASE=test
export MYSQL_USER=root
export MYSQL_PASSWORD=root
export MYSQL_HOST=127.0.0.1
export MYSQL_PORT=3306
At the moment the project is focused only on MySQL, but it is opened to implementations.
- Improve test coverage
- Add possibility to upgrade/downgrade to a specific migration
- Add command to restore dbshift in case of transactional errors
- Add command to remove a migration
- Add command to get list of all migrations with description and uuid reference