[odb-users] Manual schema migration for SQLite
boris at codesynthesis.com
Mon Jan 11 09:53:57 EST 2016
dieter.govaerts at bricsys.com <dieter.govaerts at bricsys.com> writes:
> Is there a supported way to implement a manual SQLite database schema
> migration (not data migration) to work around odb migration limitations?
> Basically I'd like suppress the generation of a schema_catalog_migrate_entry
> en define it myself.
While there is no way to suppress it, you can always skip executing this
step by implementing the "migration loop" yourself instead of calling
schema_catalog::migrate (). See the example at the end of Chapter 13.3.1,
"Immediate Data Migration".
Note also that even if we wanted to suppress the generation of a migration
step, I don't think we could, at least no easily. This is because ODB needs
to know the state of the object model after this step in order to continue
with further migrations.
There could also be complications with the "generate but skip" approach
since ODB does not support certain object model changes (e.g., removal of
the object id). In such cases it will suggest that you reimplement your
changes in terms of creating new persistent objects, etc. Which might
actually not be a bad idea: you are planning to re-build tables, etc, so
why not make ODB drop old tables and create new ones for you? To achieve
this you, for example, could change the table names of your persistent
classes (#pragma db table). To ODB this will seem as if you just deleted
one class and added another, which it will translate to dropping the old
table and creating a new one. The only potential drawback of this approach
is that you cannot "reuse" the old table names. But perhaps this is small
price to pay?
Let me know if none of this works for you or if you run into some issues.
Also, it would be great if you could share the approach you used in the
end and how it worked out.
More information about the odb-users