db schema declarative sync: no way to fail (non-zero exit) when the generated migration is destructive
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #7037 của @milekv — đã đóng, không merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Bắt đầu tại con trỏ trong apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:538-547, nơi result.dropWarnings được in ra stderr; lần theo cách các flag được khai báo cho lệnh sync và cách exit code được đặt ở những nơi khác trong CLI. Thêm cờ --fail-on-destructive (và nếu khả thi, đầu ra JSON của các cảnh báo) để lệnh trả về exit code khác không trước khi ghi migration. Kiểm chứng theo các bước tái tạo từ issue, kiểm tra echo "exit=$?" cả khi có lẫn khi không cờ, và tìm các test hiện có quanh sync handler.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.4k
- Fork
- 537
- Merge trung bình
- 20 giờ 12 phút
- Pull request đã merge (30 ngày)
- 407
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của supabase/cli
-
stack: the gateway sets no X-Forwarded-For or X-Real-IP, so Edge Functions cannot see the client IPĐang mở🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
config push: changing auth.oauth_server.authorization_url_path fails with 400 (enabled and path must be sent together)Có thể đã có người làm @itz-puneet đã nhận 4 ngày trước. Đang mở🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
supabase/cli#7087 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
📘 Docs supabase/cli
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
supabase/cli#6974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Migration error caret is missing or misplaced when the statement contains multibyte charactersĐang mở🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 Bug supabase/cli
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
phivk/rubiks-lab#33 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be editedCó thể đã có người làm @ManyaJain111 đã nhận hôm nay. Đang mởbug enhancement possible-duplicate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
AOSSIE-Org/PictoPy#1637 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
chaitin/MonkeyCode#1437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rtdb-info-connected-order test: unhandled 'connection is closed' rejection fails the CLI suiteĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cards enhancement migration ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fil-donadoni/tolaria#6309 ·
Maintainer thường phản hồi trong vòng 1 ngày