DataProvider: AddColumn with inline checkConstraint duplicates check on subsequent migrate
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 50/100
Hướng nghiên cứu
Start with DataProviderMigrate and the AddColumnOperation path that handles column-level checkConstraint values; reproduce the schema from the issue against Postgres and inspect the generated DDL. Add or update coverage for the migration, then verify that one named check constraint is created and a subsequent migrate succeeds without a duplicate-constraint error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Tool: DataProviderMigrate (CLI)
Version: latest as of 2026-05-20 (installed via dotnet tool)
Provider: postgres (Supabase)
Symptom
A migrate --allow-destructive run fails with:
Error: migration apply failed: 42710: constraint "tenant_credit_event_kind_chk" for relation "tenant_credit_event" already exists
…even when starting from a state where the column and the constraint do not yet exist (verified via information_schema.columns + pg_constraint before the run).
Schema
- name: tenant_credit_event
columns:
- name: kind
type: Text
isNullable: false
checkConstraint: "kind IN ('topup','spend','refund','adjustment')"
Hypothesis
AddColumnOperation with an inline checkConstraint appears to emit two
DDL statements in the same transaction:
ALTER TABLE … ADD COLUMN kind text NOT NULL(which Postgres auto-names the
inline constraint, e.g.tenant_credit_event_kind_check)ALTER TABLE … ADD CONSTRAINT tenant_credit_event_kind_chk CHECK (kind IN (…))
The second emit collides because the inline form was already applied — OR
DataProvider is emitting the named CONSTRAINT twice in a single batch.
Same shape visible on usage_events where prod has both
usage_events_kind_check AND usage_events_kind_chk (and equivalent
duplicates for charged_micro_usd, vendor_micro_usd, quantity). That's
the smoking gun — a previous successful run left one of each pair behind,
proving DataProvider is creating two constraints per column-level
checkConstraint.
Workaround used (prod hotfix)
Manually applied missing schema deltas via raw SQL (per user authorization
in the credit-billing rollout):
ALTER TABLE … ADD COLUMN kind text NOT NULL(no inline check)ALTER TABLE … ADD CONSTRAINT tenant_credit_event_kind_chk CHECK …(named, once)- Renamed
usage_events.ledger_id → credit_event_id DROP TABLE wallet_ledger,DROP TABLE wallet- Replaced two combined RLS policies with the four single-op ones declared
inmigrations/schema.yaml.
Ask
Either:
- Emit only the named constraint from
checkConstraint:and skip the
inline form, OR - Detect existing equivalent check constraints (same predicate / same
relation) and treat as a no-op when re-applying.
Cross-refs
- NAP incident: Nimblesite/NimblesiteAgenticPlatform#126
- PR that triggered: Nimblesite/NimblesiteAgenticPlatform#125
- Ngôn ngữ chính
- C#
- Star
- 68
- Fork
- 4
- Merge trung bình
- 50 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- 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 Nimblesite/DataProvider
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
Nimblesite/DataProvider#137 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Nimblesite/DataProvider#72 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Nimblesite/DataProvider#121 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Nimblesite/DataProvider#108 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A check constraint the schema cannot name can never be retired, and keeps enforcing the old ruleĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Nimblesite/DataProvider#107 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Nimblesite/DataProvider
Issue tương tự
-
kronos:develop:queued priority:P0
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ 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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
nopSolutions/nopCommerce#8512 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/csharp-sdk#2061 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày