From b0c2c30dd0b83ea67fb2c8375ae2061dad0d1770 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 Apr 2013 16:17:27 +0200 Subject: Add support for embedded schema migration --- evolution/template/driver.cxx | 27 ++++++++++++++++++++++++++- evolution/template/makefile | 9 +++++---- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'evolution/template') diff --git a/evolution/template/driver.cxx b/evolution/template/driver.cxx index 1e2ad90..357055d 100644 --- a/evolution/template/driver.cxx +++ b/evolution/template/driver.cxx @@ -11,6 +11,7 @@ #include #include +#include #include @@ -27,7 +28,8 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db, "test2")); // 1 - base version // 2 - migration @@ -41,6 +43,15 @@ main (int argc, char* argv[]) { using namespace v2; + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::create_schema (*db, "test2"); + schema_catalog::create_schema (*db, "test1"); + schema_catalog::migrate_schema (*db, 2, "test2"); + t.commit (); + } + { transaction t (db->begin ()); dummy d (1); @@ -53,11 +64,25 @@ main (int argc, char* argv[]) { using namespace v3; + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3, "test2"); + t.commit (); + } + { transaction t (db->begin ()); auto_ptr p (db->load (1)); t.commit (); } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3, "test2"); + t.commit (); + } break; } case 3: diff --git a/evolution/template/makefile b/evolution/template/makefile index a914292..c3fc5f7 100644 --- a/evolution/template/makefile +++ b/evolution/template/makefile @@ -29,15 +29,16 @@ $(driver): $(cxx_obj) $(common.l) $(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) $(cxx_obj) $(cxx_od): $(common.l.cpp-options) -genf1 := test1-odb.hxx test1-odb.ixx test1-odb.cxx test1.sql model.xml +genf1 := test1-odb.hxx test1-odb.ixx test1-odb.cxx model.xml gen1 := $(addprefix $(out_base)/,$(genf1)) -genf2 := test2-odb.hxx test2-odb.ixx test2-odb.cxx test2.sql \ -test2-002-pre.sql test2-002-post.sql test2-003-pre.sql test2-003-post.sql +genf2 := test2-odb.hxx test2-odb.ixx test2-odb.cxx gen2 := $(addprefix $(out_base)/,$(genf2)) genf := $(genf1) $(genf2) gen := $(gen1) $(gen2) +gens := test1.sql test2.sql test2-002-pre.sql test2-002-post.sql \ +test2-003-pre.sql test2-003-post.sql $(gen): $(odb) $(gen): odb := $(odb) @@ -113,7 +114,7 @@ $(clean): \ ifeq ($(out_base),$(src_base)) $(driver): | $(out_base)/.gitignore -$(out_base)/.gitignore: files := driver $(genf) +$(out_base)/.gitignore: files := driver $(genf) $(gens) $(clean): $(out_base)/.gitignore.clean $(call include,$(bld_root)/git/gitignore.make) -- cgit v1.1