-
Notifications
You must be signed in to change notification settings - Fork 7
123 lines (123 loc) · 3.48 KB
/
migrate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: migrate
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: go build -o /usr/local/bin/queryx cmd/queryx/main.go
- uses: actions/upload-artifact@v3
with:
name: bin
path: /usr/local/bin/queryx
sqlite:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/download-artifact@v3
with:
name: bin
path: /usr/local/bin
- run: chmod a+x /usr/local/bin/queryx
- name: migrate
run: |
cd internal/migrate
queryx db:migrate --schema sqlite1.hcl
- name: sleep
run: sleep 1 # so the generated migration files have non-conflicting filenames
- name: migrate again
run: |
cd internal/migrate
queryx db:migrate --schema sqlite2.hcl
- name: test
run: |
cd internal/migrate
sqlite3 test.sqlite3 "insert into users(name, email) values('test', 'test@example.com')"
postgresql:
needs: [build]
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.2
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: queryx_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/download-artifact@v3
with:
name: bin
path: /usr/local/bin
- run: chmod a+x /usr/local/bin/queryx
- name: migrate
run: |
cd internal/migrate
queryx db:migrate --schema postgresql1.hcl
- name: sleep
run: sleep 1
- name: migrate again
run: |
cd internal/migrate
queryx db:migrate --schema postgresql2.hcl
- name: test
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -d queryx_test -tc "insert into users(name, email) values('test', 'test@example.com')"
mysql:
needs: [build]
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0.32
env:
MYSQL_DATABASE: queryx_test
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -uuser_test -pqueryx_test"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/download-artifact@v3
with:
name: bin
path: /usr/local/bin
- run: chmod a+x /usr/local/bin/queryx
- name: migrate
run: |
cd internal/migrate
queryx db:migrate --schema mysql1.hcl
- name: sleep
run: sleep 1
- name: migrate again
run: |
cd internal/migrate
queryx db:migrate --schema mysql2.hcl
- name: test
run: |
mysql --protocol=tcp -h localhost -u root -D queryx_test -e "insert into users(name, email) values('test', 'test@example.com')"