[odb-users] [Feature request] ODB should support CREATE TABLE IF
NOT EXISTS for SQLite (and, preferably, for other drivers)
aongeeno at openmailbox.org
aongeeno at openmailbox.org
Fri Jun 16 03:29:26 EDT 2017
середа, 31 травня 2017 р. 18:11:00 EEST ви написали:
> Hi,
>
> aongeeno at openmailbox.org <aongeeno at openmailbox.org> writes:
>
> > Much better will be use supported feature CREATE TABLE IF NOT EXISTS.
>
> This is not supported by all databases/versions. We could implement
> this for those that support it but we will soon have another problem:
> what if the table exists but from some older version of our application?
> To solve this you can use ODB's database schema evolution support (Chapter
> 13) which also takes care of properly detecting whether the schema does
> not yet exist.
>
> Boris
>
Thank you! I solved my problem:
odb::transaction t(db_->begin());
odb::schema_catalog::migrate(*db_);
t.commit();
"As an extra convenience, migrate() will also create the database schema if none exists."
More information about the odb-users
mailing list