Symptom
alterTableSQL ADD COLUMN (internal/loader/hcl/sqlgen.go:724-725) never emits FIRST/AFTER; columnDefSQL has no positional clause.
Impact
New columns always land at the end of the table regardless of their declared position in HCL, so the live column order permanently diverges from the schema file. If column order is later used in comparisons or round-trip fidelity checks, this shows up as unfixable drift.
Fix direction
When a column is added, compute its declared neighbor and emit ADD COLUMN ... AFTER <prev> (or FIRST). Optionally also detect pure reorders and emit MODIFY COLUMN ... AFTER ....
Found in the 2026-07-02 deep-dive audit (docs/plans/2026-07-02-deep-dive-improvement-areas.md, B4).
Symptom
alterTableSQLADD COLUMN (internal/loader/hcl/sqlgen.go:724-725) never emitsFIRST/AFTER;columnDefSQLhas no positional clause.Impact
New columns always land at the end of the table regardless of their declared position in HCL, so the live column order permanently diverges from the schema file. If column order is later used in comparisons or round-trip fidelity checks, this shows up as unfixable drift.
Fix direction
When a column is added, compute its declared neighbor and emit
ADD COLUMN ... AFTER <prev>(orFIRST). Optionally also detect pure reorders and emitMODIFY COLUMN ... AFTER ....Found in the 2026-07-02 deep-dive audit (docs/plans/2026-07-02-deep-dive-improvement-areas.md, B4).