Migration set

Migration Set is a collection of migrations.

1migration_set "<reference>" {
2  schema = "public"
3
4  migrations = [
5    ...
6  ]
7}
  • <reference> - migration set reference name
  • schema (optional) - schema name where to create schema_migrations table and run migrations (SET search_path TO <schema> is executed before each migration), default: public
  • migrations - list of migrations references

Arguments

These attributes can be used with arguments:

  • schema - value is automatically quoted
1migration_set "tenant" {
2  arguments {
3    arg "schema" {}
4  }
5
6  schema = "{{.Args.schema}}"
7
8  migrations = [...]
9}

Example

 1migration_set "private" {
 2  migrations = [
 3    migration.create_tenants
 4  ]
 5}
 6
 7migration "create_tenants" {
 8  version = "20200628"
 9
10  up {
11    sql = "CREATE TABLE tenants(name varchar PRIMARY KEY)"
12  }
13
14  down {
15    sql = "DROP TABLE tenants"
16  }
17}