Skip to content

Commit 1167b50

Browse files
committed
Add go-migrate to Postgres role
1 parent c4276f2 commit 1167b50

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

pkg/registry/roles/postgres/tasks/main.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Run official PostgreSQL Docker container with specified version.
1818
#
1919
- name: Run PostgreSQL container
20-
docker_container:
20+
community.docker.docker_container:
2121
name: cgapp-postgres
2222
image: "postgres:{{ postgres_version }}"
2323
restart_policy: unless-stopped
@@ -28,3 +28,25 @@
2828
- "{{ postgres_port }}:{{ postgres_port }}"
2929
volumes:
3030
- "{{ server_dir }}/database/data/:/var/lib/postgresql/data"
31+
32+
#
33+
# Make DB migration.
34+
#
35+
- name: Make DB migration
36+
community.docker.docker_container:
37+
name: cgapp-db-migration
38+
image: "migrate/migrate"
39+
recreate: true
40+
networks:
41+
- name: "{{ docker_network }}"
42+
command:
43+
[
44+
"-path",
45+
"/migrations",
46+
"-database",
47+
"postgres://{{ postgres_user }}:{{ postgres_password }}@localhost:{{ postgres_port }}/{{ postgres_db }}?sslmode={{ postgres_ssl_mode }}",
48+
"up",
49+
"{{ migrate_number }}",
50+
]
51+
volumes:
52+
- "{{ server_dir }}/backend/platform/migrations/:/migrations"

pkg/registry/templates/hosts.ini.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ postgres_password=password
7070
# Set PostgreSQL DB name,
7171
# MUST BE MATCH to the DB name that is listed in your `./backend/.env` file!
7272
postgres_db=postgres
73+
# Set PostgreSQL SSL mode state ('enabled' or 'disabled'),
74+
# MUST BE MATCH to the SSL mode state that is listed in your `./backend/.env` file!
75+
postgres_ssl_mode=disable
76+
77+
#
78+
# Go-Migrate configuration:
79+
#
80+
81+
# Set migration number,
82+
# if you WANT to migrate all of your migrations, just leave it blank,
83+
# for only initial migration set it to '1'
84+
migrate_number=1
7385

7486
#
7587
# Redis configuration (backend cache):

0 commit comments

Comments
 (0)