Skip to content

Epic: Add Supabase Database Branching Provider#894

Draft
acreeger wants to merge 8 commits intomainfrom
feat/issue-272__add-supabase-db-branching
Draft

Epic: Add Supabase Database Branching Provider#894
acreeger wants to merge 8 commits intomainfrom
feat/issue-272__add-supabase-db-branching

Conversation

@acreeger
Copy link
Copy Markdown
Collaborator

Fixes #272

Epic: Add Supabase Database Branching Provider

Summary

Add Supabase as a second database branching provider, enabling users on Supabase to get isolated database branches per loom. This includes refactoring the provider architecture to cleanly support multiple database providers.

Context

iloom creates isolated Git worktrees for issues/PRs and supports database branching for full environment isolation. Currently only Neon is supported. Supabase users cannot use this isolation feature. The existing architecture anticipated multiple providers (Config.databaseProvider already includes 'supabase' in its union type) but the implementation is hardcoded to Neon.

Key Architectural Decisions

  1. Remove Neon-specific methods from DatabaseProvider interfacefindPreviewBranch() and getBranchNameFromEndpoint() are only called internally within NeonProvider. They will be removed from the interface and kept as NeonProvider-internal methods.
  2. Add provider metadata to interfacedisplayName and installHint properties allow DatabaseManager to show provider-appropriate messages instead of hardcoded "Neon CLI" references.
  3. Generic provider factorycreateDatabaseProviderFromSettings() replaces hardcoded createNeonProviderFromSettings() calls in 4 command files. Errors if both Neon and Supabase are configured.
  4. Supabase CLI integration — SupabaseProvider uses supabase branches CLI commands, consistent with the Neon CLI pattern.
  5. withData defaults to true — Supabase branches don't include production data by default (unlike Neon). The withData setting (default: true) ensures users get schema+data in their branches.
  6. Provider-agnostic prompt templates — References to "Neon" in prompt templates replaced with generic "database branching" language.

Acceptance Criteria

  • Supabase users can configure databaseProviders.supabase in settings and get isolated database branches per loom
  • Existing Neon functionality is unaffected (backwards compatible)
  • DatabaseManager shows provider-appropriate messages (not hardcoded Neon references)
  • Provider factory cleanly selects the right provider based on configuration
  • Telemetry tracks Supabase adoption alongside Neon
  • Documentation covers Supabase setup and configuration

This PR was created automatically by iloom.

…er support

- Remove findPreviewBranch and getBranchNameFromEndpoint from DatabaseProvider interface (Neon-specific)
- Add displayName and installHint required string properties to DatabaseProvider interface
- Update DatabaseManager to use provider.displayName and provider.installHint in all user-facing messages (both createBranchIfConfigured and deleteBranchIfConfigured)
- Add displayName='Neon' and installHint='npm install -g neonctl' to NeonProvider
- Update MockDatabaseProvider and DatabaseManager tests to match new interface
@acreeger acreeger force-pushed the feat/issue-272__add-supabase-db-branching branch from 2e3b101 to 800e118 Compare March 10, 2026 21:49
…rFromSettings factory

- Add SupabaseSettingsSchema to SettingsManager with projectRef, parentBranch, withData fields
- Extend DatabaseProvidersSettingsSchema with optional supabase key
- Create src/utils/database-helpers.ts with createDatabaseProviderFromSettings factory
  - Returns NeonProvider when neon is configured
  - Returns SupabaseProvider when supabase is configured
  - Throws if both are configured simultaneously
  - Returns unconfigured NeonProvider when neither is configured
- Add SupabaseProvider placeholder stub (isConfigured=false, full impl in separate issue)
- Add comprehensive tests for factory branching logic
- Document databaseProviders.supabase config in docs/iloom-commands.md
…upport

Adds SupabaseProvider class implementing DatabaseProvider interface using
supabase branches CLI commands. Includes:

- Branch creation via supabase branches create with optional --with-data
- Branch deletion with existence check before attempting removal
- Connection string retrieval parsing POSTGRES_URL_NON_POOLING from env output
- branchExists with precise error classification: only not-found errors return false,
  auth/network errors are rethrown (no silent swallowing)
- isCliAvailable using ENOENT-based binary detection via supabase --version
- isAuthenticated via supabase projects list with auth error pattern matching
- sanitizeBranchName replacing slashes with hyphens (Supabase convention)
- Graceful degradation: isConfigured returns false on invalid config without throwing
- 48 comprehensive unit tests covering all methods and edge cases

Supabase branches always fork from production; the fromBranch parameter is
accepted for interface compatibility but ignored. The --branch-name flag
does not exist in the Supabase CLI and has been omitted from branch creation.
… and templates

- Replace createNeonProviderFromSettings with createDatabaseProviderFromSettings
  in start.ts, finish.ts, cleanup.ts, and cli.ts
- Remove stale re-export of createNeonProviderFromSettings from database-helpers.ts
- Delete orphaned src/utils/neon-helpers.ts
- Rename CLI debug command test-neon to test-db using provider-agnostic interface
- Update regular-prompt.txt and issue-prompt.txt to use "database branching" language
- Add clarifying comment to SupabaseProvider.branchExists() about exitCode=1 convention
- Add `has_supabase: boolean` to `SessionStartedProperties` telemetry interface
- Wire Supabase detection in ignite command alongside existing has_neon tracking
- Add test coverage for Supabase detection in session.started telemetry
- Expand Supabase documentation with prerequisites, paid plan requirement, and withData option explanation
Adds Supabase as a database branching provider, enabling per-loom database isolation
via supabase branches CLI. Refactors DatabaseProvider interface to be provider-agnostic,
creates a generic factory, wires all commands through it, adds telemetry and documentation.

Fixes #272
Supabase always branches from the default branch so parentBranch has no
effect. Made it optional in schema, config interface, and validation.
Updated README with Supabase support mentions and example config.
Removed parentBranch from Supabase docs example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Epic: Add Supabase Database Branching Provider

1 participant