KB-2E02

IU Core MVP Sandbox — 03 Forward DDL Apply

3 min read Revision 1

IU Core MVP Sandbox — 03 Forward DDL Apply

Date: 2026-05-21 · Branch 2. Apply sql/iu-core/001..005 to restore_test ONLY. No production / live Directus DB touched.

Transfer

  • tar -czf of sql/iu-core/ (sha256 1a3e5d35…) → scp to VPS /tmpdocker cp into pg-restore-test-20260520T031054Z:/tmp/iu-core.

Pre-apply backup (sandbox safety net)

  • pg_dump -Fc restore_test/tmp/restore_test.pre-iucore.dump inside the container, sha256 e7992cd23868739570068928e32730f3639a65bbd27d4ab9c2075afaac07f1a8.
  • Pre-apply census: 3 public tables.

Apply

Command per file: psql -U postgres -d restore_test -v ON_ERROR_STOP=1 -1 -f NNN.sql.

File Result
001_iu_sql_link.sql OK — CREATE TABLE + 3 indexes + 4 COMMENT
002_iu_event_routes.sql OK — 3 CREATE TABLE + 4 indexes + 3 COMMENT
003_parent_child_constraints.sql OK — CREATE TABLE + 3 indexes + CREATE VIEW
004_structure_ops_lineage.sql OK — 2 CREATE TABLE + 6 indexes
005_trigger_contracts_and_guards.sql OK — 7 CREATE FUNCTION + CREATE VIEW

All 5 exit 0. Post-apply census: 3 → 10 public tables (7 iu-core added).

ON_ERROR_STOP behaviour

ON_ERROR_STOP=1 was set; no error occurred so no early stop was triggered. Atomicity verified later in the rollback drill (mid-file error aborts the file's own BEGIN…COMMIT).

Finding H2 — redundant psql -1

Every forward file already wraps itself in BEGIN; … COMMIT;. Adding -1 (the command form recommended by the prior authoring report 10) opens a second outer transaction, producing two harmless but misleading warnings per file:

WARNING:  there is already a transaction in progress      (the file's BEGIN)
WARNING:  there is no transaction in progress             (psql's outer COMMIT)

DDL still applies atomically (the file's own BEGIN/COMMIT). Hardened: drop -1; use psql -v ON_ERROR_STOP=1 -f. See reports 07 and 10.

Verdict

Forward DDL 001–005 applied to the sandbox restore_test with zero errors.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-mvp-sandbox-execution-hardening-rollback-drill/03-forward-ddl-apply-sandbox.md