Commit 280e76f
committed
fix(xsd): make Phase 3d content-model ingest idempotent
Compositors / child_edges / group_edges have no natural unique key
(a complexType can hold sibling sequences/choices), so the prior pass
unconditionally inserted on every run, doubling rows on the second
ingest. CT_Tbl content lookups against a re-ingested DB returned 0
rows because the order_index ranges no longer matched what queries
expected.
Switching to delete-and-rewrite per profile at the start of pass 3:
DELETE FROM xsd_compositors WHERE profile_id = ?
DELETE FROM xsd_group_edges WHERE profile_id = ?
xsd_child_edges cleans up automatically via FK CASCADE on
compositor_id. Inheritance / symbols / memberships stay upsert-only
since they have natural keys.
Idempotency test now also asserts compositor / child-edge / group-ref
counts in the DB match the first-run insert counts after a second run.
Verified: two consecutive `bun run xsd:ingest` against the WML closure
both produce 585 compositors / 2098 child edges / 161 group refs and
the DB ends at exactly those counts.1 parent 6cb04ac commit 280e76f
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
198 | 208 | | |
199 | 209 | | |
200 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
183 | 191 | | |
184 | | - | |
185 | 192 | | |
186 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
187 | 197 | | |
188 | 198 | | |
189 | 199 | | |
| |||
0 commit comments