[openstack-dev] [savanna] Alembic migrations and absence of DROP column in sqlite

Jay Pipes jaypipes at gmail.com
Thu Jan 30 20:04:35 UTC 2014


On Thu, 2014-01-30 at 14:51 -0500, Trevor McKay wrote:
> I was playing with alembic migration and discovered that
> op.drop_column() doesn't work with sqlite.  This is because sqlite
> doesn't support dropping a column (broken imho, but that's another
> discussion).  Sqlite throws a syntax error.
> 
> To make this work with sqlite, you have to copy the table to a temporary
> excluding the column(s) you don't want and delete the old one, followed
> by a rename of the new table.
> 
> The existing 002 migration uses op.drop_column(), so I'm assuming it's
> broken, too (I need to check what the migration test is doing).  I was
> working on an 003.
> 
> How do we want to handle this?  Three good options I can think of:
> 
> 1) don't support migrations for sqlite (I think "no", but maybe)
> 
> 2) Extend alembic so that op.drop_column() does the right thing (more
> open-source contributions for us, yay :) )
> 
> 3) Add our own wrapper in savanna so that we have a drop_column() method
> that wraps copy/rename.
> 
> Ideas, comments?

Migrations should really not be run against SQLite at all -- only on the
databases that would be used in production. I believe the general
direction of the contributor community is to be consistent around
testing of migrations and to not run migrations at all in unit tests
(which use SQLite).

Boris (cc'd) may have some more to say on this topic.

Best,
-jay




More information about the OpenStack-dev mailing list