Skip to content

Commit 9decdd7

Browse files
chore: add Supabase migration deploy workflow
Co-authored-by: Ona <no-reply@ona.com>
1 parent 883f777 commit 9decdd7

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy Migrations
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
env:
9+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
17+
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
18+
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: supabase/setup-cli@v1
24+
with:
25+
version: latest
26+
27+
- name: Link Supabase project
28+
run: supabase link --project-ref $SUPABASE_PROJECT_ID
29+
30+
- name: Deploy migrations
31+
run: supabase db push
32+
33+
- name: Verify critical tables exist
34+
env:
35+
SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
36+
SUPABASE_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY }}
37+
run: |
38+
tables=(page_versions collections collection_views collection_rows comments)
39+
failed=()
40+
for table in "${tables[@]}"; do
41+
body=$(curl -s \
42+
"${SUPABASE_URL}/rest/v1/${table}?limit=1" \
43+
-H "apikey: ${SUPABASE_KEY}" \
44+
-H "Authorization: Bearer ${SUPABASE_KEY}" 2>&1)
45+
if echo "$body" | grep -q "PGRST205"; then
46+
echo "MISSING: $table — $body"
47+
failed+=("$table")
48+
else
49+
echo "OK: $table"
50+
fi
51+
done
52+
53+
# Verify critical columns exist by selecting them explicitly.
54+
# PGRST204 means the column is absent from the schema cache.
55+
columns=(
56+
"pages:is_private"
57+
"pages:cover"
58+
"pages:share_token"
59+
)
60+
for entry in "${columns[@]}"; do
61+
table="${entry%%:*}"
62+
column="${entry##*:}"
63+
body=$(curl -s \
64+
"${SUPABASE_URL}/rest/v1/${table}?select=${column}&limit=1" \
65+
-H "apikey: ${SUPABASE_KEY}" \
66+
-H "Authorization: Bearer ${SUPABASE_KEY}" 2>&1)
67+
if echo "$body" | grep -qE "PGRST(204|205)"; then
68+
echo "MISSING COLUMN: ${table}.${column} — $body"
69+
failed+=("${table}.${column}}")
70+
else
71+
echo "OK: ${table}.${column}"
72+
fi
73+
done
74+
75+
if [ ${#failed[@]} -gt 0 ]; then
76+
echo "Missing from schema cache: ${failed[*]}"
77+
exit 1
78+
fi

0 commit comments

Comments
 (0)