You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] compareColumns ignores column order — reorder is reported identical #374
Schema Compare column-level diff is supposed to surface all structural changes.
Problem
src/lib/schema-diff.ts:60-100 (compareColumns) builds sourceMap = new Map(sourceColumns.map((c) => [c.name, c])) and iterates the map. A column reorder (source id, name, email vs target id, email, name) compares each column by name and finds all three — all equal, no diff. The diff reports the table as identical. sync-sql-generator won't emit any ALTER, but ALTER TABLE … MODIFY COLUMN x AFTER y would be needed to restore source order. This is a silent schema drift: a query that relies on column order (e.g., INSERT INTO t VALUES (…) without column names) would write different rows on each side.
Files
src/lib/schema-diff.ts:60-100
Repro
Create source.users (id INT, name VARCHAR(50), email VARCHAR(255))
Create target.users (id INT, email VARCHAR(255), name VARCHAR(50))
Schema Compare — table appears as identical
Expected
Diff surfaces a "Column order changed" entry; sync SQL emits MODIFY COLUMN statements to reorder.
Proposed fix
Track ordinal position per column. Add orderChanged: boolean to the table diff when [src_names].join(',') !== [tgt_names].join(',') while set contents match. sync-sql-generator adds ALTER TABLE … MODIFY COLUMN x AFTER y (or FIRST) when orderChanged. Scope: M.
Acceptance
Source id, name, email vs target id, email, name surfaces as a "Column order changed" diff entry; sync SQL emits MODIFY COLUMN statements to reorder.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the compare editor tab type, and the menu, title-bar and toolbar entry points.
Activity
EVWorth commentedon Sep 9, 2026
Closed by removing the feature.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the
compareeditor tab type, and the menu, title-bar and toolbar entry points.feat: remove schema compare (#577)