aboutsummaryrefslogtreecommitdiff
path: root/evolution/template
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-25 07:35:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-25 09:58:53 +0200
commit40ae3082645ed3790eb1d5d6f04fb2ca36c19187 (patch)
tree5157fe5db532ec91b0c06ce5f81d4e92444b7fe9 /evolution/template
parent502926d96b0b5d79dc639b8388fbf19b11cda277 (diff)
Add support for schema version table
Diffstat (limited to 'evolution/template')
-rw-r--r--evolution/template/Makefile.am23
-rw-r--r--evolution/template/driver.cxx17
-rw-r--r--evolution/template/makefile43
-rw-r--r--evolution/template/template-vc10.vcxproj13
-rw-r--r--evolution/template/template-vc10.vcxproj.filters4
-rw-r--r--evolution/template/template-vc11.vcxproj13
-rw-r--r--evolution/template/template-vc11.vcxproj.filters4
-rw-r--r--evolution/template/template-vc9.vcproj13
-rw-r--r--evolution/template/test1.hxx4
-rw-r--r--evolution/template/test2.hxx2
-rw-r--r--evolution/template/test3.hxx12
11 files changed, 106 insertions, 42 deletions
diff --git a/evolution/template/Makefile.am b/evolution/template/Makefile.am
index b5cd2d7..2d71bc3 100644
--- a/evolution/template/Makefile.am
+++ b/evolution/template/Makefile.am
@@ -34,16 +34,27 @@ test1-odb.hxx: test1.hxx
# test2.hxx
#
driver_SOURCES += test2.hxx
-nodist_driver_SOURCES += test2-odb.cxx
-BUILT_SOURCES += test2-odb.hxx
-CLEANFILES += 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
+nodist_driver_SOURCES = test2-odb.cxx
+BUILT_SOURCES = test2-odb.hxx
+CLEANFILES = test2-odb.hxx test2-odb.ixx test2-odb.cxx test2.sql
test2-odb.hxx: test2.hxx
$(ODB) $(AM_CPPFLAGS) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS) __value__(odb_options2) --changelog model.xml $<
-# Make sure test2.hxx is compiled before test1.hxx since they share the
+# test3.hxx
+#
+driver_SOURCES += test3.hxx
+nodist_driver_SOURCES += test3-odb.cxx
+BUILT_SOURCES += test3-odb.hxx
+CLEANFILES += test3-odb.hxx test3-odb.ixx test3-odb.cxx test3.sql \
+test3-002-pre.sql test3-002-post.sql test3-003-pre.sql test3-003-post.sql
+
+test3-odb.hxx: test3.hxx
+ $(ODB) $(AM_CPPFLAGS) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS) __value__(odb_options3) --changelog model.xml $<
+
+# Make sure testN.hxx are compiled serially since they share the
# changelog. Also add dependency on model.hxx
#
test2-odb.hxx: test1-odb.hxx
-test1-odb.hxx test2-odb.hxx: model.hxx
+test3-odb.hxx: test2-odb.hxx
+test1-odb.hxx test2-odb.hxx test3-odb.hxx: model.hxx
diff --git a/evolution/template/driver.cxx b/evolution/template/driver.cxx
index 357055d..b2ff10e 100644
--- a/evolution/template/driver.cxx
+++ b/evolution/template/driver.cxx
@@ -15,10 +15,10 @@
#include <common/common.hxx>
-#include "test1.hxx"
#include "test2.hxx"
-#include "test1-odb.hxx"
+#include "test3.hxx"
#include "test2-odb.hxx"
+#include "test3-odb.hxx"
using namespace std;
using namespace odb::core;
@@ -29,7 +29,7 @@ main (int argc, char* argv[])
try
{
auto_ptr<database> db (create_database (argc, argv, false));
- bool embedded (schema_catalog::exists (*db, "test2"));
+ bool embedded (schema_catalog::exists (*db));
// 1 - base version
// 2 - migration
@@ -46,9 +46,10 @@ main (int argc, char* argv[])
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");
+ schema_catalog::drop_schema (*db);
+ schema_catalog::drop_schema (*db, "2");
+ schema_catalog::create_schema (*db, "", false);
+ schema_catalog::migrate_schema (*db, 2);
t.commit ();
}
@@ -67,7 +68,7 @@ main (int argc, char* argv[])
if (embedded)
{
transaction t (db->begin ());
- schema_catalog::migrate_schema_pre (*db, 3, "test2");
+ schema_catalog::migrate_schema_pre (*db, 3);
t.commit ();
}
@@ -80,7 +81,7 @@ main (int argc, char* argv[])
if (embedded)
{
transaction t (db->begin ());
- schema_catalog::migrate_schema_post (*db, 3, "test2");
+ schema_catalog::migrate_schema_post (*db, 3);
t.commit ();
}
break;
diff --git a/evolution/template/makefile b/evolution/template/makefile
index c3fc5f7..f3a19bd 100644
--- a/evolution/template/makefile
+++ b/evolution/template/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
cxx_tun := driver.cxx
-odb_hdr := test1.hxx test2.hxx
+odb_hdr := test1.hxx test2.hxx test3.hxx
cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
cxx_od := $(cxx_obj:.o=.o.d)
@@ -29,36 +29,41 @@ $(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 model.xml
+genf1 := test1-odb.hxx test1-odb.ixx test1-odb.cxx
gen1 := $(addprefix $(out_base)/,$(genf1))
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
+genf3 := test3-odb.hxx test3-odb.ixx test3-odb.cxx
+gen3 := $(addprefix $(out_base)/,$(genf3))
+
+genf := $(genf1) $(genf2) $(genf3)
+gen := $(gen1) $(gen2) $(gen3)
+gens := test1.sql test2.sql test3.sql test3-002-pre.sql test3-002-post.sql \
+test3-003-pre.sql test3-003-post.sql
$(gen): $(odb)
$(gen): odb := $(odb)
$(gen) $(dist): odb_common_options = --database $(db_id) --generate-query \
---generate-schema --omit-create --at-once --table-prefix evo_template_ #@@ CHANGE THIS
-$(gen1) $(dist): export odb_options1 = $(odb_common_options) --schema-name \
-test1 --init-changelog --suppress-migration
-$(gen2) $(dist): export odb_options2 = $(odb_common_options) --schema-name \
-test2
+--generate-schema --at-once --table-prefix evo_template_ #@@ CHANGE THIS
+$(gen1) $(dist): export odb_options1 = $(odb_common_options) --init-changelog
+$(gen2) $(dist): export odb_options2 = $(odb_common_options) --omit-create \
+--schema-name 2 --suppress-migration
+$(gen3) $(dist): export odb_options3 = $(odb_common_options) --omit-create
$(gen1): odb_options += $(odb_options1) --changelog $(out_base)/model.xml
$(gen2): odb_options += $(odb_options2) --changelog $(out_base)/model.xml
+$(gen3): odb_options += $(odb_options3) --changelog $(out_base)/model.xml
$(gen): cpp_options := -I$(src_base)
$(gen): $(common.l.cpp-options)
$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-# Make sure test2.hxx is compiled before test1.hxx since they share the
+# Make sure testN.hxx are compiled serially since they share the
# changelog. Also add dependency on model.hxx
#
$(gen2): $(gen1)
+$(gen3): $(gen2)
$(gen): $(src_base)/model.hxx
# Alias for default target.
@@ -87,15 +92,17 @@ $(dist):
#
$(test): $(driver)
# Drop everything.
+ $(call schema,$(out_base)/test3.sql)
$(call schema,$(out_base)/test2.sql)
$(call schema,$(out_base)/test1.sql)
- # Base schema (-post is always empty).
- $(call schema,$(out_base)/test2-002-pre.sql)
+ # Base schema.
+ $(call schema,$(out_base)/test3-002-pre.sql)
+ $(call schema,$(out_base)/test3-002-post.sql)
$(call message,test $< base,$< --options-file $(dcf_root)/db.options 1)
# Migration.
- $(call schema,$(out_base)/test2-003-pre.sql)
+ $(call schema,$(out_base)/test3-003-pre.sql)
$(call message,test $< migration,$< --options-file $(dcf_root)/db.options 2)
- $(call schema,$(out_base)/test2-003-post.sql)
+ $(call schema,$(out_base)/test3-003-post.sql)
# Current schema.
$(call message,test $< current,$< --options-file $(dcf_root)/db.options 3)
@@ -107,14 +114,14 @@ $(clean): \
$(addsuffix .cxx.clean,$(cxx_od)) \
$(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
$(call message,,rm -f $(out_base)/model.xml) # Changelog.
- $(call message,,rm -f $(out_base)/test2-*.sql) # Migration files.
+ $(call message,,rm -f $(out_base)/test3-*.sql) # Migration files.
# Generated .gitignore.
#
ifeq ($(out_base),$(src_base))
$(driver): | $(out_base)/.gitignore
-$(out_base)/.gitignore: files := driver $(genf) $(gens)
+$(out_base)/.gitignore: files := driver model.xml $(genf) $(gens)
$(clean): $(out_base)/.gitignore.clean
$(call include,$(bld_root)/git/gitignore.make)
diff --git a/evolution/template/template-vc10.vcxproj b/evolution/template/template-vc10.vcxproj
index d5e7ac8..70b8687 100644
--- a/evolution/template/template-vc10.vcxproj
+++ b/evolution/template/template-vc10.vcxproj
@@ -165,20 +165,29 @@ __custom_build_entry__(
test2.hxx,
odb test2.hxx,
odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options2), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test2.hxx,
-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,
-model.xml;model.hxx)
+test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml,
+test1-odb.hxx;model.hxx)
+__custom_build_entry__(
+test3.hxx,
+odb test3.hxx,
+odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options3), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test3.hxx,
+test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql,
+test2-odb.hxx;model.hxx)
</ItemGroup>
<ItemGroup>
__header_entry__(test1-odb.hxx)
__header_entry__(test1-odb.ixx)
__header_entry__(test2-odb.hxx)
__header_entry__(test2-odb.ixx)
+__header_entry__(test3-odb.hxx)
+__header_entry__(test3-odb.ixx)
__header_entries__(extra_headers)
</ItemGroup>
<ItemGroup>
__source_entry__(driver.cxx)
__source_entry__(test1-odb.cxx)
__source_entry__(test2-odb.cxx)
+__source_entry__(test3-odb.cxx)
__source_entries__(extra_sources)
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/evolution/template/template-vc10.vcxproj.filters b/evolution/template/template-vc10.vcxproj.filters
index c467cdc..d6ac66e 100644
--- a/evolution/template/template-vc10.vcxproj.filters
+++ b/evolution/template/template-vc10.vcxproj.filters
@@ -17,12 +17,16 @@ __header_filter_entry__(test1-odb.ixx)
__header_filter_entry__(test2.hxx)
__header_filter_entry__(test2-odb.hxx)
__header_filter_entry__(test2-odb.ixx)
+__header_filter_entry__(test3.hxx)
+__header_filter_entry__(test3-odb.hxx)
+__header_filter_entry__(test3-odb.ixx)
__header_filter_entries__(extra_headers)
</ItemGroup>
<ItemGroup>
__source_filter_entry__(driver.cxx)
__source_filter_entry__(test1-odb.cxx)
__source_filter_entry__(test2-odb.cxx)
+__source_filter_entry__(test3-odb.cxx)
__source_filter_entries__(extra_sources)
</ItemGroup>
</Project>
diff --git a/evolution/template/template-vc11.vcxproj b/evolution/template/template-vc11.vcxproj
index d3bfc99..5895a46 100644
--- a/evolution/template/template-vc11.vcxproj
+++ b/evolution/template/template-vc11.vcxproj
@@ -169,20 +169,29 @@ __custom_build_entry__(
test2.hxx,
odb test2.hxx,
odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options2), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test2.hxx,
-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,
-model.xml;model.hxx)
+test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml,
+test1-odb.hxx;model.hxx)
+__custom_build_entry__(
+test3.hxx,
+odb test3.hxx,
+odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options3), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test3.hxx,
+test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql,
+test2-odb.hxx;model.hxx)
</ItemGroup>
<ItemGroup>
__header_entry__(test1-odb.hxx)
__header_entry__(test1-odb.ixx)
__header_entry__(test2-odb.hxx)
__header_entry__(test2-odb.ixx)
+__header_entry__(test3-odb.hxx)
+__header_entry__(test3-odb.ixx)
__header_entries__(extra_headers)
</ItemGroup>
<ItemGroup>
__source_entry__(driver.cxx)
__source_entry__(test1-odb.cxx)
__source_entry__(test2-odb.cxx)
+__source_entry__(test3-odb.cxx)
__source_entries__(extra_sources)
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/evolution/template/template-vc11.vcxproj.filters b/evolution/template/template-vc11.vcxproj.filters
index c467cdc..d6ac66e 100644
--- a/evolution/template/template-vc11.vcxproj.filters
+++ b/evolution/template/template-vc11.vcxproj.filters
@@ -17,12 +17,16 @@ __header_filter_entry__(test1-odb.ixx)
__header_filter_entry__(test2.hxx)
__header_filter_entry__(test2-odb.hxx)
__header_filter_entry__(test2-odb.ixx)
+__header_filter_entry__(test3.hxx)
+__header_filter_entry__(test3-odb.hxx)
+__header_filter_entry__(test3-odb.ixx)
__header_filter_entries__(extra_headers)
</ItemGroup>
<ItemGroup>
__source_filter_entry__(driver.cxx)
__source_filter_entry__(test1-odb.cxx)
__source_filter_entry__(test2-odb.cxx)
+__source_filter_entry__(test3-odb.cxx)
__source_filter_entries__(extra_sources)
</ItemGroup>
</Project>
diff --git a/evolution/template/template-vc9.vcproj b/evolution/template/template-vc9.vcproj
index 79cfb0a..4c9b465 100644
--- a/evolution/template/template-vc9.vcproj
+++ b/evolution/template/template-vc9.vcproj
@@ -339,6 +339,7 @@
__source_entry__(driver.cxx)
__source_entry__(test1-odb.cxx)
__source_entry__(test2-odb.cxx)
+__source_entry__(test3-odb.cxx)
__source_entries__(extra_sources)
</Filter>
<Filter
@@ -358,10 +359,18 @@ __file_entry_custom_build__(
test2.hxx,
odb test2.hxx,
odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options2), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test2.hxx,
-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,
-model.xml;model.hxx)
+test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml,
+test1-odb.hxx;model.hxx)
__file_entry__(test2-odb.hxx)
__file_entry__(test2-odb.ixx)
+__file_entry_custom_build__(
+test3.hxx,
+odb test3.hxx,
+odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options3), @database@, __value__(database)) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test3.hxx,
+test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql,
+test2-odb.hxx;model.hxx)
+__file_entry__(test3-odb.hxx)
+__file_entry__(test3-odb.ixx)
__file_entries__(extra_headers)
</Filter>
</Files>
diff --git a/evolution/template/test1.hxx b/evolution/template/test1.hxx
index 668033d..d6d4ac7 100644
--- a/evolution/template/test1.hxx
+++ b/evolution/template/test1.hxx
@@ -5,8 +5,6 @@
#ifndef TEST1_HXX
#define TEST1_HXX
-#define MODEL_VERSION 2
-#include "model.hxx"
-#undef MODEL_VERSION
+#pragma db model version(1, 1)
#endif // TEST1_HXX
diff --git a/evolution/template/test2.hxx b/evolution/template/test2.hxx
index 5b8e48c..a349f54 100644
--- a/evolution/template/test2.hxx
+++ b/evolution/template/test2.hxx
@@ -5,7 +5,7 @@
#ifndef TEST2_HXX
#define TEST2_HXX
-#define MODEL_VERSION 3
+#define MODEL_VERSION 2
#include "model.hxx"
#undef MODEL_VERSION
diff --git a/evolution/template/test3.hxx b/evolution/template/test3.hxx
new file mode 100644
index 0000000..68366f4
--- /dev/null
+++ b/evolution/template/test3.hxx
@@ -0,0 +1,12 @@
+// file : evolution/template/test3.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST3_HXX
+#define TEST3_HXX
+
+#define MODEL_VERSION 3
+#include "model.hxx"
+#undef MODEL_VERSION
+
+#endif // TEST3_HXX