Commit graph

2 commits

Author SHA1 Message Date
Claude
6944ec2a4f
Expand FK investigation with detection and fixing analysis
Additional findings:
- Third case that breaks FKs: changing PK away from referenced column
  (SQLite requires FK targets to be PRIMARY KEY or UNIQUE)
- Detection is easy: iterate tables, find incoming FKs, check if
  referenced columns are being renamed/dropped/losing uniqueness
- Automatic fixing for renames is moderate complexity: transform
  referencing tables first to update their FK constraints
- Challenges include circular references and transaction safety
- Proposed API: update_incoming_fks=True flag or better error messages
2026-01-21 14:38:59 +00:00
Claude
ffe2213f30
Add investigation of FK constraints during transform()
Document findings from investigation into how the transform() method
handles foreign key constraints that REFERENCE the table being transformed
(incoming FKs from other tables).

Key findings:
- Incoming FKs survive transform because SQLite's ALTER TABLE RENAME
  automatically updates FK references in the schema
- Renaming a referenced COLUMN breaks incoming FKs because SQLite
  cannot update column references
- With FK enforcement ON, transform() correctly detects and rolls back
  operations that would break FK constraints
- With FK enforcement OFF, transforms that break FKs succeed but leave
  the database in an inconsistent state

Also documents a minor issue: leftover temp tables when transform fails.
2026-01-21 14:28:44 +00:00