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
[P0][bug] SchemaSnapshot has no foreignKeys field — schema diff silently misses all FK changes; sync generator emits no FK DDL #370
Schema Compare & Sync generates CREATE/ALTER/DROP statements to bring target in line with source. FK changes are the most impactful schema changes (they affect row-level integrity).
Problem
SchemaSnapshot.tables[i] carries only { name, columns, indexes } (src/lib/schema-diff.ts:46-57). No foreignKeys field. There is no getForeignKeys Tauri command in src-tauri/src/lib.rs:180-230 invoke_handler (ARCHITECTURE §5.3 lists it but unimplemented). compareSchemas cannot diff FKs; generateSyncSQL cannot emit ADD CONSTRAINT … FOREIGN KEY … or DROP FOREIGN KEY …. A diff between source orders (FK to users) and target orders (no FK) shows as identical — silently dropping the most impactful schema change. Same root cause affects Table Designer (designer F9) — fixing this unblocks both.
src-tauri/crates/mas-core/src/schema/inspector.rs (no FK method)
Repro
Create source DB with orders table referencing users(id)
Create target DB with orders table but no FK
Schema Compare shows: "0 only in source, 0 only in target, 0 different, N identical"
Generate Sync SQL produces: empty list
Expected
Diff surfaces the FK as "Foreign Key Changes" with source/target details; sync SQL emits ALTER TABLE orders ADD CONSTRAINT … FOREIGN KEY ….
Proposed fix
(1) Add pub async fn get_foreign_keys(connection_id, database, table) -> Result<Vec<ForeignKeyInfo>, CoreError> in mas-core/src/schema/inspector.rs querying INFORMATION_SCHEMA.KEY_COLUMN_USAGE joined with REFERENTIAL_CONSTRAINTS and REFERENCED_TABLE_NAME. (2) Register in lib.rs:invoke_handler. (3) Add TS type ForeignKeyInfo and api.getForeignKeys. (4) Extend SchemaSnapshot.tables[i].foreignKeys. (5) Add compareForeignKeys to schema-diff.ts (added/removed/modified). (6) Extend sync-sql-generator.ts with ADD CONSTRAINT and DROP FOREIGN KEY. (7) Add "Foreign Key Changes" section to DiffTableItem UI. Scope: L.
Acceptance
Source orders.user_id → users.id FK with target no FK surfaces as yellow diff item; sync SQL emits ALTER TABLE orders ADD CONSTRAINT … FOREIGN KEY …. Source no FK + target FK surfaces as diff and sync emits ALTER TABLE orders DROP FOREIGN KEY ….
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)