Skip to content

Commit

Permalink
Add information about the implementation of the migrations to the rea…
Browse files Browse the repository at this point in the history
…dme.
  • Loading branch information
Jeffrey-Vervoort-KNMI committed Dec 13, 2023
1 parent f124e06 commit fd55f15
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions migrate/README.md
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`.

0 comments on commit fd55f15

Please sign in to comment.