Skip to content

4.3. Migrations

Rafał Lorenz edited this page Dec 22, 2019 · 4 revisions

Migrations are run with the use of init containers. To add migrations copy them to migrate service (which is used as an init container for your service.

cmd/migrate/Dockerfile

COPY cmd/auth/migrations /migrations
COPY cmd/user/migrations /migrations
+ COPY cmd/my-service/migrations /migrations

Then update your helm values for your service helm/app/values.yaml

my-service:
  nameOverride: auth
  serviceAccountName: goapiboilerplate
  # ... some configuration
+  initContainers:
+    - name: migrations
+      image:
+        repository: migrate
+        tag: latest
+        pullPolicy: IfNotPresent
+      command:
+        - '/migrate'
+      args:
+        - '-source'
+        - 'file:///migrations'
+        - '-database'
+        - 'mysql://root:password@tcp(go-api-boilerplate-mysql:3306)/goapiboilerplate?multiStatements=true'
+        - 'up'
Clone this wiki locally