GNOME Bugzilla – Bug 753563
migration failed with new table
Last modified: 2015-08-25 08:02:44 UTC
Created attachment 309162 [details] [review] new test patch with test attached. I'm unable to migrate correctly when the database has a new table in the new version. It simply does not create the table. Any help is much appreciated. The test attached does: -> creates a db (version 3) with only BookmarksResource at create_old_db(); -> use the same db but migrate to version 4 including SeriesResource at do_migrate() output: ERROR:tests/test-gom-migration.c:526:do_migrate: assertion failed (error == NULL): sqlite3_prepare_v2 failed: no such table: series: INSERT INTO series ('series-name', 'series-id', 'imdb-id') VALUES (?, ?, ?); ("gom-error-quark", 2)
The only change I made to your test is to mark every property, including the primary key, as being new in version 4 of the database. Note that normally, I would expect you to migrate your database by hand, and create your new table in the version, but, seeing as you're nice :)
Created attachment 309932 [details] [review] gom: Add support for creating new tables in a version To support creating new tables in a particular version of the database, we special case the primary key's "new in version" tag to create the table in that version. For example, if a table with 2 columns, one primary key, and one attribute, needs to be created in version 4 of the database, you'll need to tag both the primary key property as well as the attribute one as being new in version 4 of the database. Think of this as an easter egg, as you'd really be expected to create all the necessary tables in version 1, or to manually migrate your database otherwise.
Created attachment 309933 [details] [review] tests: Add migration with new table in version X
Attachment 309932 [details] pushed as 5ad762e - gom: Add support for creating new tables in a version Attachment 309933 [details] pushed as f70f121 - tests: Add migration with new table in version X
(In reply to Bastien Nocera from comment #1) > The only change I made to your test is to mark every property, including the > primary key, as being new in version 4 of the database. > > Note that normally, I would expect you to migrate your database by hand, and > create your new table in the version, but, seeing as you're nice :) I thought a new API would be necessary :) Many thanks for the fix and explanation.