DataProvider: AddColumn with inline checkConstraint duplicates check on subsequent migrate
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 50/100
調査の方向性
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分
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 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 日以内に返信