After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 753563 - migration failed with new table
migration failed with new table
Status: RESOLVED FIXED
Product: gom
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Gom Maintainers
Gom Maintainers
Depends on:
Blocks: 748423
 
 
Reported: 2015-08-12 15:09 UTC by Victor Toso
Modified: 2015-08-25 08:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
new test (9.78 KB, patch)
2015-08-12 15:09 UTC, Victor Toso
none Details | Review
gom: Add support for creating new tables in a version (2.15 KB, patch)
2015-08-24 22:11 UTC, Bastien Nocera
committed Details | Review
tests: Add migration with new table in version X (10.67 KB, patch)
2015-08-24 22:11 UTC, Bastien Nocera
committed Details | Review

Description Victor Toso 2015-08-12 15:09:38 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)
Comment 1 Bastien Nocera 2015-08-24 22:04:14 UTC
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 :)
Comment 2 Bastien Nocera 2015-08-24 22:11:06 UTC
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.
Comment 3 Bastien Nocera 2015-08-24 22:11:15 UTC
Created attachment 309933 [details] [review]
tests: Add migration with new table in version X
Comment 4 Bastien Nocera 2015-08-24 22:12:06 UTC
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
Comment 5 Victor Toso 2015-08-25 08:02:44 UTC
(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.