-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add information about the implementation of the migrations to the rea…
…dme.
- Loading branch information
1 parent
f124e06
commit fd55f15
Showing
1 changed file
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
# Migration Framework | ||
To have reproducible environments, support rollbacks and make sure that every change is only executed once we use [Golang Migrate](https://github.com/golang-migrate/migrate/tree/master) as migration framework. | ||
To have reproducible environments, support rollbacks and that every change is only executed once, we use [Golang Migrate](https://github.com/golang-migrate/migrate/tree/master) as a migration framework. | ||
|
||
Installation instructions and basic commands can be found here: | ||
See the following URL for installation instructions and basic commands: | ||
https://github.com/golang-migrate/migrate/tree/master/cmd/migrate | ||
|
||
Migration file format instructions can be found here: | ||
See the following URL for the migration file format instructions: | ||
https://github.com/golang-migrate/migrate/blob/master/MIGRATIONS.md | ||
|
||
## Practicalities | ||
### Initialisation | ||
The migration framework initialises the database. Therefore, no database tables exist before running the migrate step in the docker compose. | ||
|
||
### File name format | ||
The migration file name format follows the suggestion in [MIGRATIONS.md](https://github.com/golang-migrate/migrate/blob/master/MIGRATIONS.md) to use a timestamp as version. | ||
|
||
``` | ||
{version}_{title}.up.{extension} | ||
{version}_{title}.down.{extension} | ||
``` | ||
|
||
On Linux, you can retrieve the current timestamp by running: `date +%s`. | ||
|
||
|
||
### Migration Path | ||
The path `./migrate/data/migrations` is mounted on the migrate container. Thus, the docker container only executes the migrations in this path. | ||
|
||
The other path: `./migrate/data/not_supported_yet`, contains an example migration based on code comments about unfinished work from the initialise script. As the path is not mounted, the docker container does not execute migrations in that path. To try out the migrations move the files to `./migrate/data/migrations`. |