This patch implements both fromDatabase and delColumn
for sqlite. I added sqlite to the appropriate
existing tests; it passes them.
fromDatabase is done by parsing the table creation
sql from the sqlite_master table. This will work with
any sqlite 3, and I think dates back into sqlite 2,
but I'm not sure.
delColumn is implemented by renaming the table,
creating a new table without the one column, then
copying all the data over. This is obviously not as
efficient as on DBs that support drop column
directly, but it works.
This implementation of dropColumn does deal correctly
with triggers, foreign keys, and indices that
reference the table whose column is being dropped. It
does not deal correctly with triggers & indices
attached directly to the table being altered.
Attached items will be lost. Extending the
implementation to support re-creating those indices &
triggers should be straightforward, but is beyond my
needs. You are welcome to do so.
Finally, this patch slightly improves the
implementation of addColumn for sqlite. It performs a
vacuum operation after each column add. See the
sqlite documentation for why this is a good idea.
Log in to post a comment.