dingo
is a framework-agnostic lightweight cross-platform database migration tool that will keep your database schema in sync across multiple developers and deployment environments.
It's a command line tool that can be used on any project regardless of the programming language used to create it, be it Python, Go, C#, Java, Ruby, PHP or something else. This tool fits especially well with microservice architecture and services written in different languages, allowing you to have consistent and unified database migration process.
- Supports Postgres and SQL Server
- Migrations are timestamp-versioned
- Migrations are written using plain
.sql
- Project configs can be stored as
.yml
,.json
or environment variables - Use different configuration profiles for different environments
- Provides tools for rapid database development
- Apply and revert database migrations
Build Status | |
Unit Tests | |
Test Coverage | |
Version | |
Downloads | |
License | |
Docs |
To install dingo
on Linux run following commands:
curl -s https://api.github.com/repos/ujinjinjin/dingo/releases/latest \
| grep "browser_download_url.*x64.deb" \
| cut -d '"' -f 4 \
| wget -O dingo.deb -qi -
sudo dpkg --install dingo.deb
If you want to install
dingo
on aarm64
system, replacex64
witharm64
in thegrep
command
Then add /usr/share/dingo
to the $PATH
environment variable. Run following command to validate successful installation:
dingo --version
To uninstall dingo
use:
sudo dpkg --remove dingo
To install dingo
on macOS run following commands:
curl -s https://api.github.com/repos/ujinjinjin/dingo/releases/latest \
| grep "browser_download_url.*x64.pkg" \
| cut -d '"' -f 4 \
| xargs -I packageUrl curl packageUrl -L -s -o dingo.pkg
installer -pkg dingo.pkg -target CurrentUserHomeDirectory
If you want to install
dingo
on aarm64
system, replacex64
witharm64
in thegrep
command
Let's apply our first migrations on a PostgreSQL database. Firstly, create project folder:
mkdir user-service
cd user-service
Then initialize dingo
configuration profile using command below:
dingo init
The command above will create user-service/.dingo/config.yml
file. Open it and add content from the snippet below and replace HOST
, DB_NAME
, USERNAME
and PWD
with relevant values:
db:
connection-string: Server=HOST;Database=DB_NAME;User Id=USERNAME;Password=PWD;
provider: PostgreSQL
Now let's create our first migration at user-service/migrations/tables/users
:
dingo new -n create_table -p user-service/migrations/tables/users
The command will create a file user-service/migrations/tables/users/YYYYMMDDmmHHss_create_table.sql
, where YYYYMMDDmmHHss
is a timestamp. Let's open it and fill out with migration logic:
-- up
create table "user" (
user_id serial not null,
username text not null
);
-- down
drop table "user";
Now let's apply migration using following command:
dingo up -p user-service/migrations
Done! You can check your DB, migration is applied and everything should be up-to-date.
If you wish to rollback last applied patch (execute down part of migrations), you can do that using:
dingo down -p user-service/migrations
For additional information on usage refer to wiki or run:
dingo --help