DataProvider: AddColumn with inline checkConstraint duplicates check on subsequent migrate
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C#
- 星标
- 68
- 派生
- 4
- 平均合并
- 50 分钟
- 30 天内合并 PR
- 2
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Nimblesite/DataProvider 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 92/100
Nimblesite/DataProvider#137 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
Nimblesite/DataProvider#72 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
Nimblesite/DataProvider#121 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
Nimblesite/DataProvider#108 ·
维护者通常 1 天内回复
-
A check constraint the schema cannot name can never be retired, and keeps enforcing the old rule未关闭
难度 4/5 3-5 天 新手友好度 48/100
Nimblesite/DataProvider#107 ·
维护者通常 1 天内回复
查看 Nimblesite/DataProvider 的全部 Issue
相似的 Issue
-
kronos:develop:queued priority:P0
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
nopSolutions/nopCommerce#8512 ·
维护者通常 4 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
modelcontextprotocol/csharp-sdk#2061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复