From b0e61f10f4cf1b90a4fa2252f111137ebbcd3e66 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Apr 2013 07:26:40 +0200 Subject: Add schema_catalog::drop_schema(), control schema dropping in create_schema() --- doc/manual.xhtml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'doc') diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 2f68865..dfdca31 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -2852,13 +2852,18 @@ namespace odb { public: static void - create_schema (database&, const std::string& name = ""); + create_schema (database&, + const std::string& name = "", + bool drop = true); + + static void + drop_schema (database&, const std::string& name = ""); static bool - exists (database_id, const std::string& name); + exists (database_id, const std::string& name = ""); static bool - exists (const database&, const std::string& name) + exists (const database&, const std::string& name = "") }; } @@ -2871,13 +2876,21 @@ namespace odb have several separate schemas, you can use the --schema-name ODB compiler option to assign custom schema names and then use these names as a second argument - to create_schema(). If the schema is not found, - create_schema() throws the + to create_schema(). By default, create_schema() + will also delete all the database objects (tables, indexes, etc.) if + they exist prior to creating the new ones. You can change this + behavior by passing false as the third argument. The + drop_schema() function allows you to delete all the + database objects without creating the new ones.

+ +

If the schema is not found, the create_schema() and + drop_schema() functions throw the odb::unknown_schema exception. You can use the exists() function to check whether a schema for the specified database and with the specified name exists in the - catalog. Note also that the create_schema() function - should be called within a transaction.

+ catalog. Note also that the create_schema() and + drop_schema() functions should be called within a + transaction.

Finally, we can also use a custom database schema with ODB. This approach can work similarly to the standalone SQL file described above except that -- cgit v1.1