feat(cli): supabase migration#366
Conversation
🦋 Changeset detectedLatest commit: 34432e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughAdds Supabase-specific "migration mode" to the Changes
Sequence Diagram(s)sequenceDiagram
participant User as User/CLI
participant Install as Install Command
participant Detect as Supabase Detector
participant Choose as Mode Selector
participant Write as Migration Writer
participant Perms as Permissions Handler
participant FS as Filesystem
User->>Install: db install --supabase [--migration|--direct]
Install->>Install: validateInstallFlags()
Install->>Detect: detectSupabaseProject(cwd, migrationsDir?)
Detect->>FS: Check config.toml, migrations/ exist
FS-->>Detect: Filesystem state
Detect-->>Install: SupabaseProjectInfo
Install->>Choose: chooseSupabaseInstallMode(flags, projectInfo, isTTY)
alt Explicit flag set
Choose-->>Install: 'migration' or 'direct'
else TTY & no flag
Choose->>User: Interactive prompt
User-->>Choose: User choice
Choose-->>Install: Selected mode
else Non-TTY & no flag
Choose-->>Install: Default (migration if detected, else direct)
end
alt mode === 'migration'
Install->>Write: writeSupabaseEqlMigration(options)
Write->>FS: Create migrations dir if missing
Write->>FS: Write migration file with header + EQL SQL + permissions
FS-->>Write: File path & overwritten flag
Write-->>Install: Success result
else mode === 'direct'
Install->>Perms: Run direct SQL install + permissions
Perms->>FS: Execute SUPABASE_PERMISSIONS_SQL
FS-->>Perms: Permissions applied
Perms-->>Install: Install complete
end
Install-->>User: Next steps (environment-specific guidance)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/cli/src/commands/db/supabase-migration.ts (1)
102-105: Simplify the always-trueexcludeOperatorFamilyassignment.
excludeOperatorFamily || truealways resolves totrue, so this reads like conditional behavior but isn’t. Making it explicit improves readability.Proposed diff
- const eqlSql = loadBundledEqlSql({ - supabase: true, - excludeOperatorFamily: excludeOperatorFamily || true, - }) + const eqlSql = loadBundledEqlSql({ + supabase: true, + excludeOperatorFamily: true, + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/db/supabase-migration.ts` around lines 102 - 105, The call to loadBundledEqlSql passes excludeOperatorFamily || true which always evaluates to true; update the call to pass a clear boolean value or the actual variable so intent is explicit (e.g., pass excludeOperatorFamily if you want the variable honored, or pass true directly if it should always be true). Locate the loadBundledEqlSql invocation and replace the ternary/OR expression with the chosen explicit boolean or the variable name (function: loadBundledEqlSql; identifier: excludeOperatorFamily).packages/cli/src/commands/init/providers/supabase.ts (1)
19-20: Wording currently implies a prompt is always shown.In non-interactive execution, mode may be auto-selected. Consider neutral wording so this step stays accurate across environments.
Proposed text tweak
- 'Install EQL: npx `@cipherstash/cli` db install --supabase (prompts for migration vs direct)', + 'Install EQL: npx `@cipherstash/cli` db install --supabase (choose migration vs direct mode)',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/init/providers/supabase.ts` around lines 19 - 20, The help text strings currently read "'Install EQL: npx `@cipherstash/cli` db install --supabase (prompts for migration vs direct)'" and imply a prompt will always appear; update these messages in packages/cli/src/commands/init/providers/supabase.ts (the two literal string entries shown) to neutral wording that covers both interactive and non-interactive runs—for example, replace the parenthetical with "(prompts for migration vs direct when interactive)" or "(interactive prompt or auto-selected in non-interactive mode)" so the message is accurate regardless of execution mode.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/cli/src/commands/db/supabase-migration.ts`:
- Around line 102-105: The call to loadBundledEqlSql passes
excludeOperatorFamily || true which always evaluates to true; update the call to
pass a clear boolean value or the actual variable so intent is explicit (e.g.,
pass excludeOperatorFamily if you want the variable honored, or pass true
directly if it should always be true). Locate the loadBundledEqlSql invocation
and replace the ternary/OR expression with the chosen explicit boolean or the
variable name (function: loadBundledEqlSql; identifier: excludeOperatorFamily).
In `@packages/cli/src/commands/init/providers/supabase.ts`:
- Around line 19-20: The help text strings currently read "'Install EQL: npx
`@cipherstash/cli` db install --supabase (prompts for migration vs direct)'" and
imply a prompt will always appear; update these messages in
packages/cli/src/commands/init/providers/supabase.ts (the two literal string
entries shown) to neutral wording that covers both interactive and
non-interactive runs—for example, replace the parenthetical with "(prompts for
migration vs direct when interactive)" or "(interactive prompt or auto-selected
in non-interactive mode)" so the message is accurate regardless of execution
mode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3153e6a7-d201-4651-bf26-ac4d31b42dc3
📒 Files selected for processing (9)
.changeset/all-frogs-give.mdpackages/cli/src/__tests__/installer.test.tspackages/cli/src/__tests__/supabase-migration.test.tspackages/cli/src/bin/stash.tspackages/cli/src/commands/db/detect.tspackages/cli/src/commands/db/install.tspackages/cli/src/commands/db/supabase-migration.tspackages/cli/src/commands/init/providers/supabase.tspackages/cli/src/installer/index.ts
Summary by CodeRabbit
Release Notes
New Features
--migrationand--directflags todb installcommand for selecting Supabase installation modes--migrations-diroption to specify custom Supabase migrations directory pathDocumentation
db installhelp text to clarify new options and--forceoverwrite behaviorTests