Skip to content

feat(ops): cleanup-draft-orphans.cjs — sweep orphaned draft rows (#2909/#2993) - #2994

Merged
jung-thomas merged 1 commit into
DEVfrom
worktree-draft-orphan-cleanup-script-2993
Nov 2, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
worktree-draft-orphan-cleanup-script-2993

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Adds scripts/cleanup-draft-orphans.cjs, a repeatable HANA cleanup for draft rows orphaned by the draft_admin_integrity outage (#2909).

Why

With the flag on and no cascade constraints, discarding/activating a draft deleted the DRAFT_DRAFTADMINISTRATIVEDATA parent but left child rows in ADMINSERVICE_*_DRAFTS → orphans that make the active entity un-editable. #2992 stops new orphans; this clears ones already created (notably the gap between the outage and the fixed build reaching PROD).

What it does

  • Discovers real ADMINSERVICE_*_DRAFTS tables from SYS.TABLE_COLUMNS (no hardcoded list).
  • Deletes draft rows whose DRAFTADMINISTRATIVEDATA_DRAFTUUID has no matching DRAFT_DRAFTADMINISTRATIVEDATA row. Live drafts are never touched.
  • Verifies 0 orphans + unchanged live-admin count after --commit; exits 2 on unexpected state.
  • --dry-run (default) / --commit; HANA-only; idempotent.

Usage

npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --dry-run
npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --commit

Validated by hand on PROD during the 2026-11-02 incident (cleared 57 rows; 0 remaining; 11 live drafts preserved). Related: #2909, #2992, #2993.

🤖 Generated with Claude Code

…2909 (#2993)

Repeatable HANA cleanup for draft rows orphaned by draft_admin_integrity
running without cascade constraints. Discovers real ADMINSERVICE_*_DRAFTS
tables from SYS.TABLE_COLUMNS, deletes rows whose DraftAdministrativeData
parent is gone, preserves live drafts, verifies clean after commit.
--dry-run (default) / --commit. HANA-only. Idempotent.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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