diff options
-rw-r--r-- | bpkg/database.cxx | 2 | ||||
-rwxr-xr-x | bpkg/odb.sh | 1 | ||||
-rw-r--r-- | bpkg/package.hxx | 20 | ||||
-rw-r--r-- | bpkg/package.xml | 56 |
4 files changed, 41 insertions, 38 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx index e355860..a866274 100644 --- a/bpkg/database.cxx +++ b/bpkg/database.cxx @@ -41,6 +41,8 @@ namespace bpkg // Register the data migration functions. // + // NOTE: remember to qualify table names if using native statements. + // template <odb::schema_version v> using migration_entry = odb::data_migration_entry<v, DB_SCHEMA_VERSION_BASE>; diff --git a/bpkg/odb.sh b/bpkg/odb.sh index 0c8ae1b..5cd8e02 100755 --- a/bpkg/odb.sh +++ b/bpkg/odb.sh @@ -49,4 +49,5 @@ $odb "${inc[@]}" \ --hxx-prologue '#include <bpkg/wrapper-traits.hxx>' \ --hxx-prologue '#include <bpkg/value-traits.hxx>' \ --include-with-brackets --include-prefix bpkg --guard-prefix BPKG \ + --schema main --schema-version-table main.schema_version \ --sqlite-override-null package.hxx diff --git a/bpkg/package.hxx b/bpkg/package.hxx index ad45fa8..cee2dd6 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -706,7 +706,7 @@ namespace bpkg // DISTINCT clause is not required. // #pragma db view object(available_package = package) \ - table("available_package_dependencies" = "pd" inner: \ + table("main.available_package_dependencies" = "pd" inner: \ "pd.type IN ('tests', 'examples', 'benchmarks') AND " \ "pd.name = " + package::id.name + "AND" + \ "pd.version_epoch = " + package::id.version.epoch + "AND" + \ @@ -725,7 +725,7 @@ namespace bpkg // external test packages. // #pragma db view object(available_package = package) \ - table("available_package_tests" = "pt" inner: \ + table("main.available_package_tests" = "pt" inner: \ "pt.name = " + package::id.name + "AND" + \ "pt.version_epoch = " + package::id.version.epoch + "AND" + \ "pt.version_canonical_upstream = " + \ @@ -1195,8 +1195,8 @@ namespace bpkg // @@ Using raw container table since ODB doesn't support containers // in views yet. // - #pragma db view object(selected_package) \ - table("selected_package_prerequisites" = "pp" inner: \ + #pragma db view object(selected_package) \ + table("main.selected_package_prerequisites" = "pp" inner: \ "pp.prerequisite = " + selected_package::name) struct package_dependent { @@ -1209,7 +1209,7 @@ namespace bpkg // Return a count of repositories that contain this repository fragment. // - #pragma db view table("repository_fragments") + #pragma db view table("main.repository_fragments") struct fragment_repository_count { #pragma db column("count(*)") @@ -1221,7 +1221,7 @@ namespace bpkg // Return a list of repositories that contain this repository fragment. // #pragma db view object(repository) \ - table("repository_fragments" = "rfs" inner: \ + table("main.repository_fragments" = "rfs" inner: \ "rfs.repository = " + repository::name) \ object(repository_fragment inner: "rfs.fragment = " + \ repository_fragment::name) @@ -1236,7 +1236,7 @@ namespace bpkg // complement. // #pragma db view object(repository = complement) \ - table("repository_fragment_complements" = "rfc" inner: \ + table("main.repository_fragment_complements" = "rfc" inner: \ "rfc.complement = " + complement::name) \ object(repository_fragment inner: "rfc.repository_fragment = " + \ repository_fragment::name) @@ -1251,7 +1251,7 @@ namespace bpkg // prerequisite. // #pragma db view object(repository = prerequisite) \ - table("repository_fragment_prerequisites" = "rfp" inner: \ + table("main.repository_fragment_prerequisites" = "rfp" inner: \ "rfp.prerequisite = " + prerequisite::name) \ object(repository_fragment inner: "rfp.repository_fragment = " + \ repository_fragment::name) @@ -1265,7 +1265,7 @@ namespace bpkg // Return a list of packages available from this repository fragment. // #pragma db view object(repository_fragment) \ - table("available_package_locations" = "pl" inner: \ + table("main.available_package_locations" = "pl" inner: \ "pl.repository_fragment = " + repository_fragment::name) \ object(available_package = package inner: \ "pl.name = " + package::id.name + "AND" + \ @@ -1286,7 +1286,7 @@ namespace bpkg // Return a list of repository fragments the packages come from. // #pragma db view object(repository_fragment) \ - table("available_package_locations" = "pl" inner: \ + table("main.available_package_locations" = "pl" inner: \ "pl.repository_fragment = " + repository_fragment::name) \ object(available_package = package inner: \ "pl.name = " + package::id.name + "AND" + \ diff --git a/bpkg/package.xml b/bpkg/package.xml index 55e3a9a..e54829c 100644 --- a/bpkg/package.xml +++ b/bpkg/package.xml @@ -1,15 +1,15 @@ <changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="sqlite" version="1"> <changeset version="8"> - <alter-table name="repository"> + <alter-table name="main.repository"> <add-column name="local" type="INTEGER" null="true"/> </alter-table> </changeset> <changeset version="7"> - <alter-table name="available_package_dependencies"> + <alter-table name="main.available_package_dependencies"> <add-column name="type" type="TEXT" null="true"/> </alter-table> - <add-table name="available_package_tests" kind="container"> + <add-table name="main.available_package_tests" kind="container"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -42,7 +42,7 @@ <column name="version_canonical_release"/> <column name="version_revision"/> <column name="version_iteration"/> - <references table="available_package"> + <references table="main.available_package"> <column name="name"/> <column name="version_epoch"/> <column name="version_canonical_upstream"/> @@ -66,7 +66,7 @@ </changeset> <model version="6"> - <table name="repository_fragment" kind="object"> + <table name="main.repository_fragment" kind="object"> <column name="name" type="TEXT" null="true"/> <column name="url" type="TEXT" null="true"/> <column name="type" type="TEXT" null="true"/> @@ -74,12 +74,12 @@ <column name="name"/> </primary-key> </table> - <table name="repository_fragment_complements" kind="container"> + <table name="main.repository_fragment_complements" kind="container"> <column name="repository_fragment" type="TEXT" null="true"/> <column name="complement" type="TEXT" null="true"/> <foreign-key name="repository_fragment_fk" on-delete="CASCADE"> <column name="repository_fragment"/> - <references table="repository_fragment"> + <references table="main.repository_fragment"> <column name="name"/> </references> </foreign-key> @@ -88,17 +88,17 @@ </index> <foreign-key name="complement_fk" deferrable="DEFERRED"> <column name="complement"/> - <references table="repository"> + <references table="main.repository"> <column name="name"/> </references> </foreign-key> </table> - <table name="repository_fragment_prerequisites" kind="container"> + <table name="main.repository_fragment_prerequisites" kind="container"> <column name="repository_fragment" type="TEXT" null="true"/> <column name="prerequisite" type="TEXT" null="true"/> <foreign-key name="repository_fragment_fk" on-delete="CASCADE"> <column name="repository_fragment"/> - <references table="repository_fragment"> + <references table="main.repository_fragment"> <column name="name"/> </references> </foreign-key> @@ -107,12 +107,12 @@ </index> <foreign-key name="prerequisite_fk" deferrable="DEFERRED"> <column name="prerequisite"/> - <references table="repository"> + <references table="main.repository"> <column name="name"/> </references> </foreign-key> </table> - <table name="repository" kind="object"> + <table name="main.repository" kind="object"> <column name="name" type="TEXT" null="true"/> <column name="url" type="TEXT" null="true"/> <column name="type" type="TEXT" null="true"/> @@ -121,14 +121,14 @@ <column name="name"/> </primary-key> </table> - <table name="repository_fragments" kind="container"> + <table name="main.repository_fragments" kind="container"> <column name="repository" type="TEXT" null="true"/> <column name="index" type="INTEGER" null="true"/> <column name="friendly_name" type="TEXT" null="true"/> <column name="fragment" type="TEXT" null="true"/> <foreign-key name="repository_fk" on-delete="CASCADE"> <column name="repository"/> - <references table="repository"> + <references table="main.repository"> <column name="name"/> </references> </foreign-key> @@ -140,12 +140,12 @@ </index> <foreign-key name="fragment_fk" deferrable="DEFERRED"> <column name="fragment"/> - <references table="repository_fragment"> + <references table="main.repository_fragment"> <column name="name"/> </references> </foreign-key> </table> - <table name="available_package" kind="object"> + <table name="main.available_package" kind="object"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -164,7 +164,7 @@ <column name="version_iteration"/> </primary-key> </table> - <table name="available_package_locations" kind="container"> + <table name="main.available_package_locations" kind="container"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -180,7 +180,7 @@ <column name="version_canonical_release"/> <column name="version_revision"/> <column name="version_iteration"/> - <references table="available_package"> + <references table="main.available_package"> <column name="name"/> <column name="version_epoch"/> <column name="version_canonical_upstream"/> @@ -199,12 +199,12 @@ </index> <foreign-key name="repository_fragment_fk" deferrable="DEFERRED"> <column name="repository_fragment"/> - <references table="repository_fragment"> + <references table="main.repository_fragment"> <column name="name"/> </references> </foreign-key> </table> - <table name="available_package_dependencies" kind="container"> + <table name="main.available_package_dependencies" kind="container"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -222,7 +222,7 @@ <column name="version_canonical_release"/> <column name="version_revision"/> <column name="version_iteration"/> - <references table="available_package"> + <references table="main.available_package"> <column name="name"/> <column name="version_epoch"/> <column name="version_canonical_upstream"/> @@ -243,7 +243,7 @@ <column name="index"/> </index> </table> - <table name="available_package_dependency_alternatives" kind="container"> + <table name="main.available_package_dependency_alternatives" kind="container"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -276,7 +276,7 @@ <column name="version_canonical_release"/> <column name="version_revision"/> <column name="version_iteration"/> - <references table="available_package"> + <references table="main.available_package"> <column name="name"/> <column name="version_epoch"/> <column name="version_canonical_upstream"/> @@ -294,7 +294,7 @@ <column name="version_iteration"/> </index> </table> - <table name="selected_package" kind="object"> + <table name="main.selected_package" kind="object"> <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="version_epoch" type="INTEGER" null="true"/> <column name="version_canonical_upstream" type="TEXT" null="true"/> @@ -319,7 +319,7 @@ <column name="name"/> </primary-key> </table> - <table name="selected_package_prerequisites" kind="container"> + <table name="main.selected_package_prerequisites" kind="container"> <column name="package" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="prerequisite" type="TEXT" null="true" options="COLLATE NOCASE"/> <column name="min_version_epoch" type="INTEGER" null="true"/> @@ -340,7 +340,7 @@ <column name="max_open" type="INTEGER" null="true"/> <foreign-key name="package_fk" on-delete="CASCADE"> <column name="package"/> - <references table="selected_package"> + <references table="main.selected_package"> <column name="name"/> </references> </foreign-key> @@ -349,12 +349,12 @@ </index> <foreign-key name="prerequisite_fk" deferrable="DEFERRED"> <column name="prerequisite"/> - <references table="selected_package"> + <references table="main.selected_package"> <column name="name"/> </references> </foreign-key> </table> - <table name="certificate" kind="object"> + <table name="main.certificate" kind="object"> <column name="id" type="TEXT" null="true"/> <column name="fingerprint" type="TEXT" null="true"/> <column name="name" type="TEXT" null="true"/> |