https://github.com/db-journey/journey
Journey migration tool
https://github.com/db-journey/journey
cli cron database golang migration
Last synced: 11 months ago
JSON representation
Journey migration tool
- Host: GitHub
- URL: https://github.com/db-journey/journey
- Owner: db-journey
- License: mit
- Created: 2017-02-07T00:59:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-19T15:50:17.000Z (over 2 years ago)
- Last Synced: 2024-06-20T17:51:40.716Z (about 2 years ago)
- Topics: cli, cron, database, golang, migration
- Language: Go
- Size: 5.03 MB
- Stars: 101
- Watchers: 5
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Journey
[](http://unmaintained.tech/)
[](https://travis-ci.org/db-journey/journey)
[](https://godoc.org/github.com/db-journey/journey)
Journey is based on the work of @mattes on his tool "migrate": https://github.com/mattes/migrate/
## __Features__
* Super easy to implement [Driver interface](http://godoc.org/github.com/db-journey/migrate/v2/driver#Driver).
* Gracefully quit running migrations on ``^C``.
* No magic search paths routines, no hard-coded config files.
* CLI is build on top of the ``migrate`` package.
* Migration files templating
## Available Drivers
* [PostgreSQL](https://github.com/db-journey/postgresql-driver)
* [Cassandra](https://github.com/db-journey/cassandra-driver)
* [SQLite](https://github.com/db-journey/sqlite3-driver)
* [MySQL](https://github.com/db-journey/mysql-driver) ([experimental](https://github.com/mattes/migrate/issues/1#issuecomment-58728186))
* Bash (planned)
Need another driver? Just implement the [Driver interface](http://godoc.org/github.com/db-journey/migrate/v2/driver#Driver) and open a PR.
## Usage from Terminal
```bash
# install
go get github.com/db-journey/journey/v2
# create new migration file in path
journey --url driver://url --path ./migrations migrate create migration_file_xyz
# apply all available migrations
journey --url driver://url --path ./migrations migrate up
# roll back all migrations
journey --url driver://url --path ./migrations migrate down
# roll back the most recently applied migration, then run it again.
journey --url driver://url --path ./migrations migrate redo
# run down and then up command
journey --url driver://url --path ./migrations migrate reset
# show the current migration version
journey --url driver://url --path ./migrations migrate version
# apply the next n migrations
journey --url driver://url --path ./migrations migrate migrate +1
journey --url driver://url --path ./migrations migrate migrate +2
journey --url driver://url --path ./migrations migrate migrate +n
# roll back the previous n migrations
journey --url driver://url --path ./migrations migrate migrate -1
journey --url driver://url --path ./migrations migrate migrate -2
journey --url driver://url --path ./migrations migrate migrate -n
# go to specific migration
journey --url driver://url --path ./migrations migrate goto 1
journey --url driver://url --path ./migrations migrate goto 10
journey --url driver://url --path ./migrations migrate goto v
```
## CronJobs
Journey also provides a command to run scheduled jobs on databases:
```bash
journey --url driver://url --path ./cronjobs scheduler start
```
## Migration files templating
Journey supports dynamic migrations files, by using go templates.
If a file in the migrations folder has the extension `.tpl` (it must match the driver file extensions, so `.sql.tpl` for sql drivers), it will parsed and executed using journey current environment.
Example:
```bash
$ echo "create table {{.TABLE}} (id int64, name text);" >> files/20170707204006_template.up.sql.tpl
$ TABLE=a_table journey migrate
```
For more information about go templating, refer to the official doc: https://golang.org/pkg/text/template/
This feature is particularly usefull to avoid leaving sensitive data in migrations, or to make adjustments based on current environment.