[odb-users] Data migration in SQLite
Alexander Igorevich
alejandro_pnz at icloud.com
Tue Dec 13 09:46:57 EST 2016
> On Dec 13, 2016, at 5:34 PM, Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Hi Alexander,
>
> Alexander Igorevich <alejandro_pnz at icloud.com> writes:
>
>> #pragma db model version(2, 2, open)
>>
>> #pragma db model version(1, 1, closed)
>
> This means no migration is possible from version 1 to 2 which means
> you should end up here:
>
>
>> if (v < bv)
>> {
>> // Error: migration from this version is no longer supported.
>> }
>
> Did you actually run it under the debugger to examine the control
> flow?
>
> Boris
Yea, I run it under debugger - it works like should works - after adding new class (2nd version),
running next code segment:
for (v = schema_catalog::next_version (db, v);
v <= cv;
v = schema_catalog::next_version (db, v))
{
transaction t (db.begin ());
schema_catalog::migrate_schema_pre (db, v);
// Data migration goes here.
schema_catalog::migrate_schema_post (db, v);
t.commit ();
}
I’ve tried to use different functions at this place - schema_catalog::migrate_schema_pre, schema_catalog::migrate_schema_post, schema_catalog:migrate_schema, schema_catalog::migrate_data, but no one of them doesn’t add new class in the database. If I re-create database, this class is added perfectly. How can I add new class using migrate function of the ODB?
More information about the odb-users
mailing list