Auto-apply the Supabase schema on merge (idempotent schema.sql + psql action) - #131
Merged
Merged
Conversation
Make supabase/schema.sql fully idempotent (DROP POLICY IF EXISTS before each CREATE POLICY; tables/indexes already IF NOT EXISTS; constraint via DROP/ADD; grants re-granted) so it can be applied repeatedly and safely. Add supabase-deploy.yml, which on merge to main runs it against the database in a single transaction with psql, gated on a SUPABASE_DB_URL secret (dormant until set; push-to-main only so the secret is never exposed to PRs). Fix the SchemaSyncTest table regex to anchor at line start so a comment isn't read as a table. Documented in supabase/README.md; LESSONS #55. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ArC3EFNefEqRZrYkm9WobY
Set up the Supabase integration from the dashboard's Cursor/Claude quickstart: - .mcp.json: the Supabase MCP server (HTTP) at project scope, pinned to the project_ref, with the docs/account/database/debugging/development/functions/ branching features. Each user still authenticates it themselves (claude /mcp). - .agents/skills + skills-lock.json: the official Supabase and supabase-postgres-best-practices skills, added via `npx skills add`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ArC3EFNefEqRZrYkm9WobY
mapgie
marked this pull request as ready for review
September 11, 2026 08:52
The deploy-action commit touched a .kt test, which requires a fragment. Patch bump; the change is developer tooling with no app-visible effect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ArC3EFNefEqRZrYkm9WobY
…provements-6v6en0 # Conflicts: # LESSONS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a phone-friendly way to keep the database in sync with the repo, without the Supabase CLI, without Branching, and without a paid plan.
What this does
supabase/schema.sqlfully idempotent. Policies nowDROP POLICY IF EXISTSbefore eachCREATE POLICY(tables/indexes were alreadyIF NOT EXISTS, the constraint uses DROP/ADD, grants re-grant). The whole file is safe to apply any number of times and never touches row data (DDL only)..github/workflows/supabase-deploy.yml. On every merge tomain, it runsschema.sqlagainst the database in a single transaction withpsql:SUPABASE_DB_URLsecret is set (prints a notice and passes), and runs only on push tomain, so the secret is never exposed to pull requests.supabase/README.mddocuments the by-hand and automatic paths and the one secret (must be the Session pooler URI, which is IPv4).LESSONS.mdVisual refresh: typography hierarchy, 8pt spacing, and component polish #57 records the approach. Also anchors theSchemaSyncTesttable regex to line start so a comment isn't misread as a table.The one secret you add (from a phone)
SUPABASE_DB_URL= Dashboard → Connect → Session pooler URI (it contains the DB password, so it lives only as a GitHub Actions secret: Settings → Secrets and variables → Actions → New repository secret). Use the Session pooler, not the direct connection, because GitHub runners are IPv4-only.Notes
main(the previous follow-up, FAB tap/hold gesture, collapsible chore groups, and the "Eventually" schema fix #125, is already merged and released, andmainhas since moved to v0.35.2).🤖 Generated with Claude Code
https://claude.ai/code/session_01ArC3EFNefEqRZrYkm9WobY
Generated by Claude Code