Skip to content

Commit 637ddef

Browse files
committed
feat: add ci check that pg dump is the same before and after running migrations
1 parent 5d766db commit 637ddef

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,23 @@ jobs:
9797

9898
- name: Verify migration idempotency
9999
run: |
100-
psql "${{ env.DATABASE_URL }}" -c "DROP TABLE IF EXISTS storage.migrations;"
100+
pg_dump "$DATABASE_URL" \
101+
--exclude-table-data=storage.migrations \
102+
| grep -v '^\\restrict' \
103+
| grep -v '^\\unrestrict' \
104+
> before.sql
105+
106+
psql "$DATABASE_URL" -c "DROP TABLE IF EXISTS storage.migrations;"
101107
npm run migration:run
108+
109+
pg_dump "$DATABASE_URL" \
110+
--exclude-table-data=storage.migrations \
111+
| grep -v '^\\restrict' \
112+
| grep -v '^\\unrestrict' \
113+
> after.sql
114+
115+
diff before.sql after.sql || (echo 'Schema mismatch!'; exit 1)
116+
102117
env:
103118
PGRST_JWT_SECRET: ${{ secrets.PGRST_JWT_SECRET }}
104119
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1/postgres

0 commit comments

Comments
 (0)