Skip to content

Auto-apply the Supabase schema on merge (idempotent schema.sql + psql action) - #131

Merged
mapgie merged 4 commits into
mainfrom
claude/task-app-ui-improvements-6v6en0
Sep 11, 2026
Merged

Auto-apply the Supabase schema on merge (idempotent schema.sql + psql action)#131
mapgie merged 4 commits into
mainfrom
claude/task-app-ui-improvements-6v6en0

Conversation

@mapgie

@mapgie mapgie commented Sep 11, 2026

Copy link
Copy Markdown
Owner

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

  • Makes supabase/schema.sql fully idempotent. Policies now DROP POLICY IF EXISTS before each CREATE POLICY (tables/indexes were already IF 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).
  • Adds .github/workflows/supabase-deploy.yml. On every merge to main, it runs schema.sql against the database in a single transaction with psql:
    psql "$SUPABASE_DB_URL" --set ON_ERROR_STOP=1 --single-transaction -f supabase/schema.sql
    
    It's dormant until the SUPABASE_DB_URL secret is set (prints a notice and passes), and runs only on push to main, so the secret is never exposed to pull requests.
  • Docs + guard. supabase/README.md documents the by-hand and automatic paths and the one secret (must be the Session pooler URI, which is IPv4). LESSONS.md Visual refresh: typography hierarchy, 8pt spacing, and component polish #57 records the approach. Also anchors the SchemaSyncTest table 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

🤖 Generated with Claude Code

https://claude.ai/code/session_01ArC3EFNefEqRZrYkm9WobY


Generated by Claude Code

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
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
@mapgie
mapgie merged commit b6cf304 into main Sep 11, 2026
7 checks passed
@mapgie
mapgie deleted the claude/task-app-ui-improvements-6v6en0 branch September 11, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants