diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-03-28 16:04:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-10 18:46:46 +0200 |
commit | e7f6315882ef16939f99dd757eaf800b9f12e92b (patch) | |
tree | afbcb4a014e042360aec70d516cfbe17ffac6563 /common | |
parent | a8dfcfcff2534695ae19015fd33cb26fd2fb88c6 (diff) |
Add changelog support for add/drop index/foreign key
Also diagnose changes to primary keys and establish the 'alters'
association.
Diffstat (limited to 'common')
46 files changed, 971 insertions, 7 deletions
diff --git a/common/changelog/add-foreign-key-diff.xml b/common/changelog/add-foreign-key-diff.xml new file mode 100644 index 0000000..34c0952 --- /dev/null +++ b/common/changelog/add-foreign-key-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="INTEGER" null="true"/> + <add-foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-mssql-diff.xml b/common/changelog/add-foreign-key-mssql-diff.xml new file mode 100644 index 0000000..594f253 --- /dev/null +++ b/common/changelog/add-foreign-key-mssql-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="INT" null="true"/> + <add-foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-mssql-patch.xml b/common/changelog/add-foreign-key-mssql-patch.xml new file mode 100644 index 0000000..17e5d14 --- /dev/null +++ b/common/changelog/add-foreign-key-mssql-patch.xml @@ -0,0 +1,23 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="o1" type="INT" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-mysql-diff.xml b/common/changelog/add-foreign-key-mysql-diff.xml new file mode 100644 index 0000000..594f253 --- /dev/null +++ b/common/changelog/add-foreign-key-mysql-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="INT" null="true"/> + <add-foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-mysql-patch.xml b/common/changelog/add-foreign-key-mysql-patch.xml new file mode 100644 index 0000000..17e5d14 --- /dev/null +++ b/common/changelog/add-foreign-key-mysql-patch.xml @@ -0,0 +1,23 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="o1" type="INT" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-oracle-diff.xml b/common/changelog/add-foreign-key-oracle-diff.xml new file mode 100644 index 0000000..14f2357 --- /dev/null +++ b/common/changelog/add-foreign-key-oracle-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="NUMBER(10)" null="true"/> + <add-foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-oracle-patch.xml b/common/changelog/add-foreign-key-oracle-patch.xml new file mode 100644 index 0000000..6168736 --- /dev/null +++ b/common/changelog/add-foreign-key-oracle-patch.xml @@ -0,0 +1,23 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="o1" type="NUMBER(10)" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-pgsql-diff.xml b/common/changelog/add-foreign-key-pgsql-diff.xml new file mode 100644 index 0000000..34c0952 --- /dev/null +++ b/common/changelog/add-foreign-key-pgsql-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="INTEGER" null="true"/> + <add-foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-pgsql-patch.xml b/common/changelog/add-foreign-key-pgsql-patch.xml new file mode 100644 index 0000000..e70ad87 --- /dev/null +++ b/common/changelog/add-foreign-key-pgsql-patch.xml @@ -0,0 +1,23 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="o1" type="INTEGER" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-sqlite-diff.xml b/common/changelog/add-foreign-key-sqlite-diff.xml new file mode 100644 index 0000000..34c0952 --- /dev/null +++ b/common/changelog/add-foreign-key-sqlite-diff.xml @@ -0,0 +1,28 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="o1" type="INTEGER" null="true"/> + <add-foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </add-foreign-key> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key-sqlite-patch.xml b/common/changelog/add-foreign-key-sqlite-patch.xml new file mode 100644 index 0000000..e70ad87 --- /dev/null +++ b/common/changelog/add-foreign-key-sqlite-patch.xml @@ -0,0 +1,23 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="o1" type="INTEGER" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-foreign-key.hxx b/common/changelog/add-foreign-key.hxx new file mode 100644 index 0000000..d6cec68 --- /dev/null +++ b/common/changelog/add-foreign-key.hxx @@ -0,0 +1,30 @@ +// file : common/changelog/add-foreign-key.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_FOREIGN_KEY_HXX +#define ADD_FOREIGN_KEY_HXX + +#pragma db model version(BVER, CVER, true) + +struct object1; + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER > 1 + object1* o1; +#endif +}; + +#pragma db object +struct object1 +{ + #pragma db id + int id; +}; + +#endif // ADD_FOREIGN_KEY_HXX diff --git a/common/changelog/add-index-mssql-diff.xml b/common/changelog/add-index-mssql-diff.xml new file mode 100644 index 0000000..33634f8 --- /dev/null +++ b/common/changelog/add-index-mssql-diff.xml @@ -0,0 +1,21 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="y" type="INT" null="false"/> + <add-index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </add-index> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="x" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-mssql-patch.xml b/common/changelog/add-index-mssql-patch.xml new file mode 100644 index 0000000..cac5886 --- /dev/null +++ b/common/changelog/add-index-mssql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="x" type="INT" null="false"/> + <column name="y" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-mysql-diff.xml b/common/changelog/add-index-mysql-diff.xml new file mode 100644 index 0000000..33634f8 --- /dev/null +++ b/common/changelog/add-index-mysql-diff.xml @@ -0,0 +1,21 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="y" type="INT" null="false"/> + <add-index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </add-index> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="x" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-mysql-patch.xml b/common/changelog/add-index-mysql-patch.xml new file mode 100644 index 0000000..cac5886 --- /dev/null +++ b/common/changelog/add-index-mysql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="x" type="INT" null="false"/> + <column name="y" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-oracle-diff.xml b/common/changelog/add-index-oracle-diff.xml new file mode 100644 index 0000000..d32bada --- /dev/null +++ b/common/changelog/add-index-oracle-diff.xml @@ -0,0 +1,21 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="y" type="NUMBER(10)" null="false"/> + <add-index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </add-index> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="x" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-oracle-patch.xml b/common/changelog/add-index-oracle-patch.xml new file mode 100644 index 0000000..91353a9 --- /dev/null +++ b/common/changelog/add-index-oracle-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="x" type="NUMBER(10)" null="false"/> + <column name="y" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-pgsql-diff.xml b/common/changelog/add-index-pgsql-diff.xml new file mode 100644 index 0000000..969abd8 --- /dev/null +++ b/common/changelog/add-index-pgsql-diff.xml @@ -0,0 +1,21 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="y" type="INTEGER" null="false"/> + <add-index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </add-index> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="x" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-pgsql-patch.xml b/common/changelog/add-index-pgsql-patch.xml new file mode 100644 index 0000000..559dd4d --- /dev/null +++ b/common/changelog/add-index-pgsql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="x" type="INTEGER" null="false"/> + <column name="y" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-sqlite-diff.xml b/common/changelog/add-index-sqlite-diff.xml new file mode 100644 index 0000000..969abd8 --- /dev/null +++ b/common/changelog/add-index-sqlite-diff.xml @@ -0,0 +1,21 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <add-column name="y" type="INTEGER" null="false"/> + <add-index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </add-index> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="x" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index-sqlite-patch.xml b/common/changelog/add-index-sqlite-patch.xml new file mode 100644 index 0000000..559dd4d --- /dev/null +++ b/common/changelog/add-index-sqlite-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="x" type="INTEGER" null="false"/> + <column name="y" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="xy_i" type="UNIQUE"> + <column name="x"/> + <column name="y" options="DESC"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/add-index.hxx b/common/changelog/add-index.hxx new file mode 100644 index 0000000..92437ab --- /dev/null +++ b/common/changelog/add-index.hxx @@ -0,0 +1,25 @@ +// file : common/changelog/add-index.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_INDEX_HXX +#define ADD_INDEX_HXX + +#pragma db model version(BVER, CVER, true) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + + int x; + +#if CVER > 1 + int y; + #pragma db index ("xy_i") unique member(x) member(y, "DESC") +#endif + +}; + +#endif // ADD_INDEX_HXX diff --git a/common/changelog/drop-foreign-key-mssql-diff.xml b/common/changelog/drop-foreign-key-mssql-diff.xml new file mode 100644 index 0000000..30dba42 --- /dev/null +++ b/common/changelog/drop-foreign-key-mssql-diff.xml @@ -0,0 +1,30 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-foreign-key name="object_o1_fk"/> + <drop-column name="o1"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="o1" type="INT" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-mssql-patch.xml b/common/changelog/drop-foreign-key-mssql-patch.xml new file mode 100644 index 0000000..b6d6e63 --- /dev/null +++ b/common/changelog/drop-foreign-key-mssql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-mysql-diff.xml b/common/changelog/drop-foreign-key-mysql-diff.xml new file mode 100644 index 0000000..30dba42 --- /dev/null +++ b/common/changelog/drop-foreign-key-mysql-diff.xml @@ -0,0 +1,30 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-foreign-key name="object_o1_fk"/> + <drop-column name="o1"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="o1" type="INT" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-mysql-patch.xml b/common/changelog/drop-foreign-key-mysql-patch.xml new file mode 100644 index 0000000..b6d6e63 --- /dev/null +++ b/common/changelog/drop-foreign-key-mysql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INT" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-oracle-diff.xml b/common/changelog/drop-foreign-key-oracle-diff.xml new file mode 100644 index 0000000..8a36172 --- /dev/null +++ b/common/changelog/drop-foreign-key-oracle-diff.xml @@ -0,0 +1,30 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-foreign-key name="object_o1_fk"/> + <drop-column name="o1"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="o1" type="NUMBER(10)" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="object_o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-oracle-patch.xml b/common/changelog/drop-foreign-key-oracle-patch.xml new file mode 100644 index 0000000..f544817 --- /dev/null +++ b/common/changelog/drop-foreign-key-oracle-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="NUMBER(10)" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-pgsql-diff.xml b/common/changelog/drop-foreign-key-pgsql-diff.xml new file mode 100644 index 0000000..8f7c6f1 --- /dev/null +++ b/common/changelog/drop-foreign-key-pgsql-diff.xml @@ -0,0 +1,30 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-foreign-key name="o1_fk"/> + <drop-column name="o1"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="o1" type="INTEGER" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-pgsql-patch.xml b/common/changelog/drop-foreign-key-pgsql-patch.xml new file mode 100644 index 0000000..a666b86 --- /dev/null +++ b/common/changelog/drop-foreign-key-pgsql-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-sqlite-diff.xml b/common/changelog/drop-foreign-key-sqlite-diff.xml new file mode 100644 index 0000000..8f7c6f1 --- /dev/null +++ b/common/changelog/drop-foreign-key-sqlite-diff.xml @@ -0,0 +1,30 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-foreign-key name="o1_fk"/> + <drop-column name="o1"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="o1" type="INTEGER" null="true"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <foreign-key name="o1_fk" deferred="true"> + <column name="o1"/> + <references table="object1"> + <column name="id"/> + </references> + </foreign-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key-sqlite-patch.xml b/common/changelog/drop-foreign-key-sqlite-patch.xml new file mode 100644 index 0000000..a666b86 --- /dev/null +++ b/common/changelog/drop-foreign-key-sqlite-patch.xml @@ -0,0 +1,16 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + <table name="object1"> + <column name="id" type="INTEGER" null="false"/> + <primary-key> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-foreign-key.hxx b/common/changelog/drop-foreign-key.hxx new file mode 100644 index 0000000..4a70c6b --- /dev/null +++ b/common/changelog/drop-foreign-key.hxx @@ -0,0 +1,30 @@ +// file : common/changelog/drop-foreign-key.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_FOREIGN_KEY_HXX +#define DROP_FOREIGN_KEY_HXX + +#pragma db model version(BVER, CVER, true) + +struct object1; + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER == 1 + object1* o1; +#endif +}; + +#pragma db object +struct object1 +{ + #pragma db id + int id; +}; + +#endif // DROP_FOREIGN_KEY_HXX diff --git a/common/changelog/drop-index-mssql-diff.xml b/common/changelog/drop-index-mssql-diff.xml new file mode 100644 index 0000000..4bf9fb8 --- /dev/null +++ b/common/changelog/drop-index-mssql-diff.xml @@ -0,0 +1,20 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-index name="num_i"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="num" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="num_i"> + <column name="num"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-mssql-patch.xml b/common/changelog/drop-index-mssql-patch.xml new file mode 100644 index 0000000..44de8f2 --- /dev/null +++ b/common/changelog/drop-index-mssql-patch.xml @@ -0,0 +1,11 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="num" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-mysql-diff.xml b/common/changelog/drop-index-mysql-diff.xml new file mode 100644 index 0000000..4bf9fb8 --- /dev/null +++ b/common/changelog/drop-index-mysql-diff.xml @@ -0,0 +1,20 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-index name="num_i"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="num" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="num_i"> + <column name="num"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-mysql-patch.xml b/common/changelog/drop-index-mysql-patch.xml new file mode 100644 index 0000000..44de8f2 --- /dev/null +++ b/common/changelog/drop-index-mysql-patch.xml @@ -0,0 +1,11 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INT" null="false"/> + <column name="num" type="INT" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-oracle-diff.xml b/common/changelog/drop-index-oracle-diff.xml new file mode 100644 index 0000000..9c717e6 --- /dev/null +++ b/common/changelog/drop-index-oracle-diff.xml @@ -0,0 +1,20 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-index name="object_num_i"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="num" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="object_num_i"> + <column name="num"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-oracle-patch.xml b/common/changelog/drop-index-oracle-patch.xml new file mode 100644 index 0000000..a517a59 --- /dev/null +++ b/common/changelog/drop-index-oracle-patch.xml @@ -0,0 +1,11 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="NUMBER(10)" null="false"/> + <column name="num" type="NUMBER(10)" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-pgsql-diff.xml b/common/changelog/drop-index-pgsql-diff.xml new file mode 100644 index 0000000..e3c0d1d --- /dev/null +++ b/common/changelog/drop-index-pgsql-diff.xml @@ -0,0 +1,20 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-index name="object_num_i"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="num" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="object_num_i"> + <column name="num"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-pgsql-patch.xml b/common/changelog/drop-index-pgsql-patch.xml new file mode 100644 index 0000000..10958e6 --- /dev/null +++ b/common/changelog/drop-index-pgsql-patch.xml @@ -0,0 +1,11 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="num" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-sqlite-diff.xml b/common/changelog/drop-index-sqlite-diff.xml new file mode 100644 index 0000000..e3c0d1d --- /dev/null +++ b/common/changelog/drop-index-sqlite-diff.xml @@ -0,0 +1,20 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <changeset version="2"> + <alter-table name="object"> + <drop-index name="object_num_i"/> + </alter-table> + </changeset> + + <model version="1"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="num" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + <index name="object_num_i"> + <column name="num"/> + </index> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index-sqlite-patch.xml b/common/changelog/drop-index-sqlite-patch.xml new file mode 100644 index 0000000..10958e6 --- /dev/null +++ b/common/changelog/drop-index-sqlite-patch.xml @@ -0,0 +1,11 @@ +<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" version="1"> + <model version="2"> + <table name="object"> + <column name="id" type="INTEGER" null="false"/> + <column name="num" type="INTEGER" null="false"/> + <primary-key auto="true"> + <column name="id"/> + </primary-key> + </table> + </model> +</changelog> diff --git a/common/changelog/drop-index.hxx b/common/changelog/drop-index.hxx new file mode 100644 index 0000000..f1f1846 --- /dev/null +++ b/common/changelog/drop-index.hxx @@ -0,0 +1,22 @@ +// file : common/changelog/drop-index.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_INDEX_HXX +#define DROP_INDEX_HXX + +#pragma db model version(BVER, CVER, true) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER == 1 + #pragma db index +#endif + int num; +}; + +#endif // DROP_INDEX_HXX diff --git a/common/changelog/makefile b/common/changelog/makefile index 1349509..0e4ecf9 100644 --- a/common/changelog/makefile +++ b/common/changelog/makefile @@ -4,13 +4,17 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make -odb_hdr := \ -model.hxx \ -add-table.hxx \ -drop-table.hxx \ -add-column.hxx \ -drop-column.hxx \ -alter-column.hxx +odb_hdr := \ +model.hxx \ +add-table.hxx \ +drop-table.hxx \ +add-column.hxx \ +drop-column.hxx \ +alter-column.hxx \ +add-index.hxx \ +drop-index.hxx \ +add-foreign-key.hxx \ +drop-foreign-key.hxx common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options |