On Mar 22, 2011, at 12:44 PM, jaypipes wrote: > Hello all, > > I've decided to post here because bug reports and the mailing list for > sqlalchemy-migrate don't seem to be monitored any more...
I don't see a post regarding this issue at http://groups.google.com/group/migrate-users , have you tried posting ? There's not much chance anyone on the list here would have any way of helping. In particular migrate does a lot of hacks to make "migrations" on SQLite work. > > I have an issue where for some reason a Table object's metadata is not > properly showing changes to the underlying database schema after a > migration, but only when the engine is SQLite. > > Our "images" table has a column ("type") removed when moving from > version 2 to version 3. I put together a simple test case that > verifies the upgrade removes the "type" column and that a downgrade > adds the "type" column back. > > My test case looks like this: > > migration_api.db_sync(self.options, 3) > > cur_version = migration_api.db_version(self.options) > self.assertEquals(3, cur_version) > > # We are now on version 3. Type column should not exist. > # Let's downgrade and check that > # the type column exists again... > > images_table = Table('images', MetaData(), autoload=True, > autoload_with=self.engine) > > self.assertTrue('type' not in images_table.c, > "'type' column found in images table columns! > " > "images table columns: %s" > % images_table.c.keys()) > > migration_api.downgrade(self.options, 2) > > cur_version = migration_api.db_version(self.options) > self.assertEquals(2, cur_version) > > images_table = Table('images', MetaData(), autoload=True, > autoload_with=self.engine) > > if using_sqlite: > cmd = "sqlite3 glance_test_migration.sqlite \".schema > images\"" > > exitcode, out, err = execute(cmd) > self.assertEqual(0, exitcode) > self.assertTrue('type VARCHAR(30)' in out) > else: > out = "" > > self.assertTrue('type' in images_table.c, > "'type' column not found in images table > columns! " > "images table columns reported by metadata: %s > \n" > "sqlite reported: %s\n" > > When running the test with MySQL, the test and migration works > perfectly fine. > > Unfortunately, when running with SQLite, I get the following: > > FAIL: test_XXX (tests.unit.test_migrations.TestMigrations) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/XXX/tests/unit/test_migrations.py", line 103, in test_XXX > % (images_table.c.keys(), out)) > AssertionError: 'type' column not found in images table columns! > images table columns reported by metadata: [u'id', u'name', u'size', > u'status', u'is_public', u'location', u'created_at', u'updated_at', > u'deleted_at', u'deleted', u'disk_format', u'container_format'] > sqlite reported: CREATE TABLE images ( > id INTEGER NOT NULL, > name VARCHAR(255), > size INTEGER, > type VARCHAR(30), > status VARCHAR(30) NOT NULL, > is_public BOOLEAN NOT NULL, > location TEXT, > created_at DATETIME NOT NULL, > updated_at DATETIME, > deleted_at DATETIME, > deleted BOOLEAN NOT NULL, > PRIMARY KEY (id), > CHECK (is_public IN (0, 1)), > CHECK (deleted IN (0, 1)) > ); > CREATE INDEX ix_images_deleted ON images (deleted); > CREATE INDEX ix_images_is_public ON images (is_public); > > % (images_table.c.keys(), out)) > > You can see above the the metadata shows the *old* schema incorrectly, > but directly querying the sqlite database shows that the migration > succeeded and the "type" column is indeed added back to the images > table. > > Is there some trick with metadata and the SQLite datastore that I'm > missing that prevents the metadata from being refreshed properly? > > Any help most appreciated! > -jay > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
