Repository navigation
fix(db): draft cascade FK via .hdbconstraint (was HDI-illegal inline FK) (#2993) - #3002
Merged
Merged
Conversation
…able (#2993) The #2993 build patch injected FOREIGN KEY ... ON DELETE CASCADE directly into each generated *_drafts.hdbtable. HDI rejects that (error 8250014: 'this artifact type must not have references to other objects') — an .hdbtable cannot carry references. Result: HDI make failed with 96 errors across 46 draft tables, crashing tutorials-db-deployer and aborting the entire MTA deploy (observed on the 2026-11-02 DEV deploy). Fix: generate a standalone *.hdbconstraint artifact per draft table instead (plugin com.sap.hana.di.constraint, already registered in the generated .hdiconfig). Format confirmed against SAP-samples (hana-shine-xsa PO_CONST.hdbconstraint): the bare SQL body with NO ALTER TABLE/ADD verb — CONSTRAINT <name> ON "<child>" FOREIGN KEY ("DRAFTADMINISTRATIVEDATA_DRAFTUUID") REFERENCES "DRAFT_DRAFTADMINISTRATIVEDATA" ("DRAFTUUID") ON DELETE CASCADE The .hdbtable is left untouched. Verified against the deployed DEV container that DRAFT_DRAFTADMINISTRATIVEDATA lives in the same HDI container schema with PK DRAFTUUID, so HDI's ALTER TABLE ADD CONSTRAINT resolves the reference at deploy time even though the table is CAP-runtime-created, not an HDI artifact. Generator produces 46 .hdbconstraint files against a real production build; the draft_admin_integrity flag stays OFF in package.json (this only makes the constraints deployable). Unit tests rewritten for the new output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The #2993 build patch (
scripts/patch-draft-cascade-constraints.cjs) injectedFOREIGN KEY ... ON DELETE CASCADEinline into each generated*_drafts.hdbtable. HDI rejects that:An
.hdbtableartifact cannot carry references. This crashedtutorials-db-deployerand aborted the entire MTA deploy on the 2026-11-02 DEV run (after the app itself built + started fine).Fix
Generate a standalone
.hdbconstraintartifact per draft table instead (plugincom.sap.hana.di.constraint, already registered in the generated.hdiconfig). The.hdbtableis left untouched.Format confirmed against SAP-samples (
hana-shine-xsacore-db/src/data/PO_CONST.hdbconstraint) — bare SQL body, noALTER TABLE ... ADD CONSTRAINTverb:Why it resolves at deploy time
DRAFT_DRAFTADMINISTRATIVEDATAis created by the CAP runtime (not an HDI artifact). Verified against the deployed DEV container that it lives in the same HDI container schema as the draft tables (CURRENT_SCHEMAmatch) with primary keyDRAFTUUID— so theALTER TABLE ... ADD CONSTRAINTHDI renders resolves the reference.Scope / safety
.hdbconstraintfiles against a realcds build --production;.hdbtablefiles unchanged (0 inline FK).cds.fiori.draft_admin_integritystays OFF in package.json — this only makes the constraints deployable; enabling thedaddelete strategy is a separate step (Re-enable draft_admin_integrity only after deploying real ADMINSERVICE_*_DRAFTS cascade constraints #2993)..hdbconstraintoutput (5 pass).Related: #2993, #2909.
🤖 Generated with Claude Code