Closed
Description
SQLite's ALTER TABLE
can only do the following:
- Rename a table
- Rename a column
- Add a column
Notably, it cannot drop columns - so tricks like "add a float version of this text column, populate it, then drop the old one and rename" won't work.
The docs here https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes describe a way of implementing full alters safely within a transaction, but it's fiddly.
- Create new table
- Copy data
- Drop old table
- Rename new into old
It would be great if sqlite-utils
provided an abstraction to help make these kinds of changes safely.