KB-56EB

IU Core Controlled Route — 03 Migrations 006 (H4) + 007 (version_seq)

2 min read Revision 1
dieu44iu-core-mvpcontrolled-routemigration-006migration-007h4version-seqv0.62026-05-21

IU Core Controlled Route — 03 Migrations 006 + 007

Two idempotent reconcile migrations were applied to production directus.

Migration 006 — H4 reconcile (applied)

006_structure_op_enacted_chk_fix.sqlALTER TABLE … DROP CONSTRAINT IF EXISTS … ADD CONSTRAINT. Reconciles iu_structure_operation_enacted_chk.

  • Before: CHECK ((operation_status = 'enacted') = (enacted_at IS NOT NULL))
  • After: CHECK ((enacted_at IS NOT NULL) = (operation_status IN ('enacted', 'rolled_back')))

The documented enacted -> rolled_back transition now keeps enacted_at instead of being forced to null it. iu_structure_operation is empty so ADD CONSTRAINT validated 0 rows — instantaneous. No table, no trigger.

Migration 007 — version_seq divergence reconcile (applied)

007_outbound_version_seq_filter.sqlCREATE OR REPLACE FUNCTION fn_iu_outbound_on_version. Resolves the divergence flagged by the COEXIST ruling (runtime-activation doc 04).

  • Before: outbound emitted on every version. body md5 0949b28b….
  • After: outbound emits only for version_seq > 1 — early-return IF NEW.version_seq IS NULL OR NEW.version_seq <= 1 THEN RETURN NULL. body md5 ff5feef8….

This mirrors the pre-existing iu_notification_event path (fn_iu_notif_version, which filters version_seq > 1). The two sinks for version_applied now share identical emit semantics; the workflow bus carries no birth-version (version_seq = 1) noise. The master-gate check stays first — fail-closed contract preserved. The change strictly reduces emissions, so it cannot create a row the pre-007 body would not have created.

Repo-ahead-of-production reconcile pattern

Both 004 (H4) and 005 (version_seq) were patched in-place so a fresh apply of 001..007 is already correct; 006/007 exist only to reconcile the production DB, which applied 004/005 before those patches. Each forward file has a matching rollback/. rollback/007 restores emit-on-every-version.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-controlled-route-mastergate-structure-observability-open-goal/03-migrations-006-007.md