forked from Calebux/SYNCRO
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.66 KB
/
Copy pathdatabase.yml
File metadata and controls
81 lines (68 loc) · 2.66 KB
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
name: Database Migrations
on:
push:
branches: [main, develop]
paths:
- "supabase/migrations/**"
- "supabase/config.toml"
pull_request:
branches: [main, develop]
paths:
- "supabase/migrations/**"
- "supabase/config.toml"
jobs:
validate-migrations:
name: Validate Migrations
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup Supabase CLI
uses: supabase/setup-cli@v3
with:
version: latest
- name: Start Supabase local stack
run: supabase start
- name: Apply all migrations
run: supabase db push
- name: Lint SQL migrations
run: supabase db lint
- name: Setup Node.js for RLS audit
uses: actions/setup-node@v7
with:
node-version: "20"
cache: "npm"
cache-dependency-path: backend/package-lock.json
- name: Install dependencies for RLS audit
working-directory: backend
run: npm install
- name: Dump live schema for snapshot comparison
run: supabase db dump --local --schema-only -f /tmp/live-schema.sql
- name: Run migration drift check against local database
id: local-drift-check
env:
SUPABASE_URL: http://127.0.0.1:54321
SUPABASE_SERVICE_ROLE_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
run: |
echo "🔍 Verifying migration history and schema against local database..."
node scripts/check-migration-drift.js \
--verify-db \
--verify-schema \
--compare-schema supabase/schema.snapshot.sql \
--live-schema /tmp/live-schema.sql \
--env local \
--strict \
--json > local-drift-result.json
cat local-drift-result.json
- name: Run RLS Policy Audit
env:
SUPABASE_URL: http://localhost:54321
# Official Supabase demo token for local CI - only works with localhost:54321
SUPABASE_SERVICE_ROLE_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
run: |
echo "🔍 Auditing RLS policies after migration..."
node scripts/check-rls-compliance.js
- name: Stop Supabase local stack
if: always()
run: if command -v supabase &> /dev/null; then supabase stop; fi