db schema declarative sync: no way to fail (non-zero exit) when the generated migration is destructive
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #7037 来自 @milekv —— 已关闭,未合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- cli
调研方向
从 apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:538-547 处的指针开始,那里 result.dropWarnings 被打印到 stderr;追踪 sync 命令的标志是如何声明的,以及 CLI 中其他地方是如何设置退出码的。添加一个 --fail-on-destructive 标志(如可行,再加一个警告的 JSON 输出),使命令在写入迁移文件之前返回非零退出码。按照 issue 中的复现步骤进行验证,在带与不带该标志两种情况下检查 echo "exit=$?",并查找 sync handler 周围已有的测试。
由索引模型根据 Issue 内容生成。
描述
Summary
supabase db schema declarative sync --no-apply prints Found destructive changes in schema diff. Please double check if these are expected: to stderr when the planned migration contains drops. It still writes the migration file and exits 0. CI jobs and scripted workflows cannot tell a destructive plan from a safe one without scraping the human-readable stderr text. --output-format json does not help either: this command prints no JSON.
Feature request: a flag such as --fail-on-destructive, or a distinct non-zero exit code, that makes sync fail when the plan contains destructive changes. Ideally the flag would also skip writing the migration file. Including the drop warnings in --output-format json would also help.
Environment
- Supabase CLI 2.119.0 (npm package, darwin-arm64), bundled
@supabase/pg-delta1.0.0-alpha.56 - Postgres 17.11 (
public.ecr.aws/supabase/postgres:17.11.0.002) - macOS 26 (Darwin 25.3.0, arm64)
Steps to reproduce
-
supabase init, then add one migration:CREATE TABLE public.d (id int); -
Run:
supabase start supabase db reset --local supabase db schema declarative generate --local --overwrite rm supabase/schemas/public/tables/d.sql supabase db schema declarative sync --no-apply; echo "exit=$?"
Expected
A supported way to make this run fail on a destructive plan, either through an opt-in flag or a dedicated exit code, so a pipeline can stop before a drop is committed.
Actual
Applying migration 20260101000007_table.sql...
Generated migration SQL:
DROP TABLE "public"."d";
Created new migration at supabase/migrations/20261006190533_declarative_sync.sql
Found destructive changes in schema diff. Please double check if these are expected:
DROP TABLE "public"."d"
exit=0
supabase db schema declarative sync --no-apply --output-format json gives the same plain-text output and also exits 0.
Impact
Sync runs unattended (in CI, a pre-commit check, or an agent loop) and sees exit code 0. A schema file that was deleted or moved by mistake therefore becomes a committed DROP TABLE migration without any gate. The warning already exists. It just cannot be acted on programmatically.
Pointer
In the v2.119.0 tag (c66274cc6dc278a9413a6b0f099367ce150555ac), apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:538-547 prints result.dropWarnings to stderr after the migration file is written. Execution then continues to the apply decision, and nothing changes the exit status. result.dropWarnings already has the data a flag would need.
- 主要语言
- TypeScript
- 星标
- 2.4k
- 派生
- 531
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 346
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
supabase/cli 的其他 Issue
-
stack: the HTTP gateway closes idle keep-alive connections after 5 s, so a client whose event loop is blocked gets ECONNRESET (`fetch failed`) on its next request可能已有人在做 @7ttp 于 5 天前认领。 未关闭🐛 Bug supabase/cli
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
📘 Docs supabase/cli
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
🐛 Bug supabase/cli
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
config push sends [auth.sms] enable_confirmations un-negated as sms_autoconfirm, so hosted projects get the opposite of local可能已有人在做 @7ttp 于 3 天前认领。 未关闭🐛 Bug supabase/cli
维护者通常 1 天内回复
-
stack: gateway still opens a new upstream connection per request on 2.119.0 (exhausts ephemeral ports on macOS)可能已有人在做 @rbSparky 于 1 天前认领。 未关闭🐛 Bug open-for-contribution supabase/cli
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrently未关闭area:testing bug effort:S priority:P2
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
lens:agent lens:process process
难度 2/5 1-3 小时 新手友好度 82/100
thebristolsound/birdbrain#1772 ·
维护者通常 1 天内回复
-
bug priority:low ready-for-dev
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
Automattic/data-liberation-agent#685 ·
维护者通常 1 天内回复
-
Business
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复