feat(cli): add declarative schema apply command by ametel01 · Pull Request #5694 · supabase/cli · GitHub
Skip to content

feat(cli): add declarative schema apply command#5694

Open
ametel01 wants to merge 4 commits into
supabase:developfrom
ametel01:feat/declarative-apply-local
Open

feat(cli): add declarative schema apply command#5694
ametel01 wants to merge 4 commits into
supabase:developfrom
ametel01:feat/declarative-apply-local

Conversation

@ametel01

Copy link
Copy Markdown
Contributor

Summary

Adds supabase db schema declarative apply for applying existing declarative schema files directly to the local database via pg-delta.

This keeps the flow separate from timestamped migrations: it starts the local database when needed, mounts the configured declarative schema directory read-only, runs the pg-delta apply script, and leaves migration files/history untouched. The PR also wires the Go command surface, adds regression coverage, and documents the native legacy side effects.

Closes #5204.

@ametel01 ametel01 requested a review from a team as a code owner June 25, 2026 10:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18966bf66e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/commands/db/shared/legacy-pgdelta.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c405ae87e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve pg-delta diagnostics on Go apply failures

When the newly registered Go apply path reaches this call and pg-delta returns a structured non-success status, pgdelta.ApplyDeclarative still returns immediately from RunEdgeRuntimeScript on the script's forced non-zero exit before unmarshalling stdout (apps/cli-go/internal/pgdelta/apply.go). Fresh evidence: this line is the new public entry point to that helper. Invalid declarative schemas therefore show only the generic container error instead of the formatted errors, stuck statements, or validation output.

Useful? React with 👍 / 👎.

Comment on lines +88 to +90

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return a success payload for JSON output modes

When users run this new native command with --output-format json or --output-format stream-json, the success path only writes human text to stderr and then returns, so stdout is empty instead of a machine-readable success/result event. Other native legacy handlers branch on output.format and call output.success(...); without that here, scripted callers that opt into the global JSON modes cannot reliably detect a successful apply from stdout.

Useful? React with 👍 / 👎.

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.

declarative: Ability to import declarative schemas directly to local DB, without having to go through migrations

1 participant