8000 chore: validate schema file on ci · asisstan/postgres@ba3e0e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba3e0e2

Browse files
committed
chore: validate schema file on ci
1 parent ebde4bb commit ba3e0e2

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,16 @@ jobs:
8080
PGPORT: 5478
8181
PGUSER: postgres
8282
PGPASSWORD: ${{ env.POSTGRES_PASSWORD }}
83+
84+
schema:
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v3
88+
- name: verify schema.sql is committed
89+
run: |
90+
docker compose up db dbmate --abort-on-container-exit
91+
if ! git diff --ignore-space-at-eol --exit-code --quiet migrations/schema.sql; then
92+
echo "Detected uncommitted changes after build. See status below:"
93+
git diff
94+
exit 1
95+
fi

migrations/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POSTGRES_PASSWORD=password
2+
DATABASE_URL="postgres://postgres:${POSTGRES_PASSWORD}@localhost:5478/postgres?sslmode=disable"

migrations/db/migrations/100000022_test.sql

Lines changed: 0 additions & 5 deletions
This file was deleted.

migrations/docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ services:
4545
volumes:
4646
- ./tests:/tests
4747
command: pg_prove /tests/test.sql
48+
49+
dbmate:
50+
image: ghcr.io/amacneil/dbmate:1
51+
depends_on:
52+
db:
53+
condition: service_healthy
54+
volumes:
55+
- ./schema.sql:/db/schema.sql
56+
environment:
57+
DATABASE_URL: postgres://supabase_admin:${POSTGRES_PASSWORD}@db/postgres?sslmode=disable
58+
command: dump

migrations/db/schema.sql renamed to migrations/schema.sql

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -991,24 +991,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
991991
-- Dbmate schema migrations
992992
--
993993

994-
INSERT INTO public.schema_migrations (version) VALUES
995-
('00000000000000'),
996-
('00000000000001'),
997-
('00000000000002'),
998-
('00000000000003'),
999-
('10000000000000'),
1000-
('20211115181400'),
1001-
('20211118015519'),
1002-
('20211122051245'),
1003-
('20211124212715'),
1004-
('20211130151719'),
1005-
('20220118070449'),
1006-
('20220126121436'),
1007-
('20220224211803'),
1008-
('20220317095840'),
1009-
('20220321174452'),
1010-
('20220322085208'),
1011-
('20220404205710'),
1012-
('20220609081115'),
1013-
('20220613123923'),
1014-
('20220713082019');

0 commit comments

Comments
 (0)
0