top | item 46901203

(no title)

lun3x | 24 days ago

Tried it out now with SQLite to see what it does with difficult migrations, like adding a foreign key constraint to an existing table. Looks like it just generates invalid migrations, eg:

`ALTER TABLE books ADD CONSTRAINT fk_books_author FOREIGN KEY (author_id) REFERENCES authors (id)`

Which is not valid in SQLite (https://www.sqlite.org/lang_altertable.html)

discuss

order

Akronymus|24 days ago

So you have to drop and re-add a column when adding foreign keys?

lun3x|24 days ago

The SQLite docs have a section about it, the idea is: 1. Create new table with foreign key constraint 2. Copy data from old to new 3. Drop old table 4. Rename new table to old name