Skip to content

fix(db): draft cascade FK via .hdbconstraint (was HDI-illegal inline FK) (#2993) - #3002

Merged
jung-thomas merged 1 commit into
DEVfrom
worktree-unblock-disable-cascade-patch-2993
Nov 3, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
worktree-unblock-disable-cascade-patch-2993

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

The #2993 build patch (scripts/patch-draft-cascade-constraints.cjs) injected FOREIGN KEY ... ON DELETE CASCADE inline into each generated *_drafts.hdbtable. HDI rejects that:

Error: com.sap.hana.di.table: "db://DRAFT_DRAFTADMINISTRATIVEDATA": this artifact type must not have references to other objects [8250014]
Make failed (96 errors): ... tutorials-db-deployer ... Process failed.

An .hdbtable artifact cannot carry references. This crashed tutorials-db-deployer and aborted the entire MTA deploy on the 2026-11-02 DEV run (after the app itself built + started fine).

Fix

Generate a standalone .hdbconstraint artifact per draft table instead (plugin com.sap.hana.di.constraint, already registered in the generated .hdiconfig). The .hdbtable is left untouched.

Format confirmed against SAP-samples (hana-shine-xsa core-db/src/data/PO_CONST.hdbconstraint) — bare SQL body, no ALTER TABLE ... ADD CONSTRAINT verb:

CONSTRAINT AdminService_Missions_drafts_dadFkCascade
ON "AdminService_Missions_drafts" FOREIGN KEY ("DRAFTADMINISTRATIVEDATA_DRAFTUUID")
REFERENCES "DRAFT_DRAFTADMINISTRATIVEDATA" ("DRAFTUUID") ON DELETE CASCADE

Why it resolves at deploy time

DRAFT_DRAFTADMINISTRATIVEDATA is 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_SCHEMA match) with primary key DRAFTUUID — so the ALTER TABLE ... ADD CONSTRAINT HDI renders resolves the reference.

Scope / safety

Related: #2993, #2909.

🤖 Generated with Claude Code

…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>
@jung-thomas
jung-thomas merged commit f386769 into DEV Nov 3, 2026
3 of 4 checks passed
@jung-thomas
jung-thomas deleted the worktree-unblock-disable-cascade-patch-2993 branch November 3, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant