KB-231A

10 — Rollback Plan (Đ30)

3 min read Revision 1
registries-pivotrollbackdieu30reversiblebegin-rollback2026-05-31

title: 10 — Rollback Plan date: 2026-05-31

10 — Rollback Plan (Đ30)

Nothing was committed this run → the operative rollback is "already rolled back": every rehearsal used BEGIN..ROLLBACK and the final sweep confirms entry == exit (six objects 0, parent_code non-null 0, pivot_definitions 37, idle 0). The plans below are for the future gated commits.

R1 — Six-object foundation (after RG1+RG2)

999_rollback.sql (SHA dddb2b40…), executable, drops in reverse dependency order:

DROP FUNCTION IF EXISTS fn_registries_pivot_node_substrate(text);
DROP VIEW IF EXISTS v_living_lists;
DROP VIEW IF EXISTS v_count_drift;
DROP VIEW IF EXISTS v_count_integrity;
DROP VIEW IF EXISTS v_registries_pivot_tree;
DROP VIEW IF EXISTS v_registry_leaf_set;
  • Pure read-layer → drop removes no data, changes no base table.
  • Idempotent (IF EXISTS); safe to run repeatedly.
  • Dry-run verification: the rehearsal's S1 POST six_post=0 / fn_post=0 is the rollback dry-run — the objects were created and removed within the transaction, proving the create/drop pair is clean. ✔

R2 — Missing-pivot bundle (after its gate)

Rows are additive to pivot_definitions. Rollback:

DELETE FROM pivot_definitions WHERE code IN ('PIV-500','PIV-301','PIV-302','PIV-303','PIV-311');
DROP VIEW IF EXISTS v_count_rollup_src;   -- helper view
  • The DELETE fires one statement-level refresh (bounded) → recomputes pivot_results to the pre-bundle state. Verified-equivalent by the INSERT 0 5 → ROLLBACK → pd_post=37 rehearsal.
  • If committed is_active=false, no live surface changes until activation, so rollback is invisible to users.

R3 — parent_code drilldown (after its gate)

UPDATE pivot_definitions SET parent_code = NULL
WHERE code IN ('PIV-101','PIV-102','PIV-106','PIV-201','PIV-202','PIV-203','PIV-204',
               'PIV-205','PIV-206','PIV-104','PIV-105','PIV-103','MTX-L2-ATOM');
  • One statement → one refresh; restores flat tree (37 roots). Verified-equivalent by D6 UPDATE 13 → ROLLBACK → non_null_post 0.

R4 — Additive tables (registry_pin, display_policy — Macro 2)

DROP TABLE IF EXISTS registry_pin;
DROP TABLE IF EXISTS display_policy;

NEW tables → drop removes only their own (proposal/config) rows; no base data affected.

R5 — UI preview v2 (Macro 3)

Static host: rm -rf /opt/incomex/docker/nginx/static/ui-preview/registries-pivot/v2/. No DB/Nuxt mutation. v1 remains untouched.

Standing safety rules (applied this run, mandatory for commits)

  • Always SET LOCAL lock_timeout / statement_timeout / idle_in_transaction_session_timeout.
  • ON_ERROR_STOP=1 → any error aborts the whole transaction (clean).
  • Never leave an idle transaction (verified idle_in_tx = 0 after every section).
  • Pivot writes: ONE batch statement only (never row-by-row → repeated refresh).
Back to Knowledge Hub knowledge/dev/reports/architecture/registries-pivot-macro1-ratify-foundation-pivot-drilldown-2026-05-31/10-rollback-plan.md