[odb-users] how to determine whether tables already exist?

Christian Sell christian at gsvitec.com
Tue Dec 30 20:49:33 EST 2014


Hello,
 
I need to determine in my application whether database creation has already been
executed, and if not, create it (on demand, so to speak). I thought this would
be the easiest of all things, but am finally forced to resort to this list. What
I want is something like
 

if(!odb::schema_catalog::exists(*db, "nyschema")) {
  odb::transaction t(c->begin());
  odb::schema_catalog::create_schema(*db, "myschema", false);
  t.commit();
}

However, the call to exists() seems to check the existence of the schema mapping
code, not the existence of the schema in the database (always returns true for
me).

How can I perform the described check?

thanks,
Chris



More information about the odb-users mailing list