aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-12-03 20:30:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-12-08 16:03:46 +0300
commit4bc9390c48cee736917ead5d20aa216fe10bae47 (patch)
treebe1736676d0ed13863d7574a1afd089bf708312f /libbrep
parent76c2215ff5aa74f53a028112787ec10593d45715 (diff)
Prepare for supporting multiple dependencies in dependency alternative
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/package.hxx56
-rw-r--r--libbrep/package.xml113
2 files changed, 160 insertions, 9 deletions
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 0ce8553..1927298 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 21
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 21, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 22, closed)
namespace brep
{
@@ -156,7 +156,17 @@ namespace brep
operator!= (const dependency&, const dependency&);
#pragma db value
- class dependency_alternatives: public vector<dependency>
+ class dependency_alternative: public small_vector<dependency, 1>
+ {
+ public:
+ optional<string> enable;
+
+ dependency_alternative () = default;
+ dependency_alternative (optional<string> e): enable (move (e)) {}
+ };
+
+ #pragma db value
+ class dependency_alternatives: public small_vector<dependency_alternative, 1>
{
public:
bool conditional;
@@ -183,7 +193,7 @@ namespace brep
test_dependency_type t,
bool b,
optional<version_constraint> c)
- : dependency {std::move (n), std::move (c), nullptr /* package */},
+ : dependency {move (n), move (c), nullptr /* package */},
type (t),
buildtime (b)
{
@@ -551,20 +561,48 @@ namespace brep
// dependencies
//
- using _dependency_key = odb::nested_key<dependency_alternatives>;
+ // Note that this is a 2-level nested container which is mapped to three
+ // container tables each containing data of each dimension.
+
+ // Container of the dependency_alternatives values.
+ //
+ #pragma db member(dependencies) id_column("") value_column("")
+
+ // Container of the dependency_alternative values.
+ //
+ using _dependency_alternative_key =
+ odb::nested_key<dependency_alternatives>;
+
using _dependency_alternatives_type =
- std::map<_dependency_key, dependency>;
+ std::map<_dependency_alternative_key, dependency_alternative>;
- #pragma db value(_dependency_key)
- #pragma db member(_dependency_key::outer) column("dependency_index")
- #pragma db member(_dependency_key::inner) column("index")
+ #pragma db value(_dependency_alternative_key)
+ #pragma db member(_dependency_alternative_key::outer) column("dependency_index")
+ #pragma db member(_dependency_alternative_key::inner) column("index")
- #pragma db member(dependencies) id_column("") value_column("")
#pragma db member(dependency_alternatives) \
virtual(_dependency_alternatives_type) \
after(dependencies) \
get(odb::nested_get (this.dependencies)) \
set(odb::nested_set (this.dependencies, std::move (?))) \
+ id_column("") key_column("") value_column("")
+
+ // Container of the dependency values.
+ //
+ using _dependency_key = odb::nested2_key<dependency_alternatives>;
+ using _dependency_alternative_dependencies_type =
+ std::map<_dependency_key, dependency>;
+
+ #pragma db value(_dependency_key)
+ #pragma db member(_dependency_key::outer) column("dependency_index")
+ #pragma db member(_dependency_key::middle) column("alternative_index")
+ #pragma db member(_dependency_key::inner) column("index")
+
+ #pragma db member(dependency_alternative_dependencies) \
+ virtual(_dependency_alternative_dependencies_type) \
+ after(dependency_alternatives) \
+ get(odb::nested2_get (this.dependencies)) \
+ set(odb::nested2_set (this.dependencies, std::move (?))) \
id_column("") key_column("") value_column("dep_")
// requirements
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 69f5731..9e162ed 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,117 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="22">
+ <alter-table name="package_dependency_alternatives">
+ <add-column name="enable" type="TEXT" null="true"/>
+ <drop-foreign-key name="dep_package_tenant_fk"/>
+ <drop-foreign-key name="dep_package_fk"/>
+ <drop-column name="dep_name"/>
+ <drop-column name="dep_min_version_epoch"/>
+ <drop-column name="dep_min_version_canonical_upstream"/>
+ <drop-column name="dep_min_version_canonical_release"/>
+ <drop-column name="dep_min_version_revision"/>
+ <drop-column name="dep_min_version_upstream"/>
+ <drop-column name="dep_min_version_release"/>
+ <drop-column name="dep_max_version_epoch"/>
+ <drop-column name="dep_max_version_canonical_upstream"/>
+ <drop-column name="dep_max_version_canonical_release"/>
+ <drop-column name="dep_max_version_revision"/>
+ <drop-column name="dep_max_version_upstream"/>
+ <drop-column name="dep_max_version_release"/>
+ <drop-column name="dep_min_open"/>
+ <drop-column name="dep_max_open"/>
+ <drop-column name="dep_package_tenant"/>
+ <drop-column name="dep_package_name"/>
+ <drop-column name="dep_package_version_epoch"/>
+ <drop-column name="dep_package_version_canonical_upstream"/>
+ <drop-column name="dep_package_version_canonical_release"/>
+ <drop-column name="dep_package_version_revision"/>
+ </alter-table>
+ <add-table name="package_dependency_alternative_dependencies" kind="container">
+ <column name="tenant" type="TEXT" null="false"/>
+ <column name="name" type="CITEXT" null="false"/>
+ <column name="version_epoch" type="INTEGER" null="false"/>
+ <column name="version_canonical_upstream" type="TEXT" null="false"/>
+ <column name="version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
+ <column name="version_revision" type="INTEGER" null="false"/>
+ <column name="dependency_index" type="BIGINT" null="false"/>
+ <column name="alternative_index" type="BIGINT" null="false"/>
+ <column name="index" type="BIGINT" null="false"/>
+ <column name="dep_name" type="CITEXT" null="false"/>
+ <column name="dep_min_version_epoch" type="INTEGER" null="true"/>
+ <column name="dep_min_version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="dep_min_version_canonical_release" type="TEXT" null="true"/>
+ <column name="dep_min_version_revision" type="INTEGER" null="true"/>
+ <column name="dep_min_version_upstream" type="TEXT" null="true"/>
+ <column name="dep_min_version_release" type="TEXT" null="true"/>
+ <column name="dep_max_version_epoch" type="INTEGER" null="true"/>
+ <column name="dep_max_version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="dep_max_version_canonical_release" type="TEXT" null="true"/>
+ <column name="dep_max_version_revision" type="INTEGER" null="true"/>
+ <column name="dep_max_version_upstream" type="TEXT" null="true"/>
+ <column name="dep_max_version_release" type="TEXT" null="true"/>
+ <column name="dep_min_open" type="BOOLEAN" null="true"/>
+ <column name="dep_max_open" type="BOOLEAN" null="true"/>
+ <column name="dep_package_tenant" type="TEXT" null="true"/>
+ <column name="dep_package_name" type="CITEXT" null="true"/>
+ <column name="dep_package_version_epoch" type="INTEGER" null="true"/>
+ <column name="dep_package_version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="dep_package_version_canonical_release" type="TEXT" null="true" options="COLLATE &quot;C&quot;"/>
+ <column name="dep_package_version_revision" type="INTEGER" null="true"/>
+ <foreign-key name="tenant_fk" deferrable="DEFERRED">
+ <column name="tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </foreign-key>
+ <foreign-key name="object_id_fk" on-delete="CASCADE">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ <references table="package">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </foreign-key>
+ <index name="package_dependency_alternative_dependencies_object_id_i">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </index>
+ <foreign-key name="dep_package_tenant_fk" deferrable="DEFERRED">
+ <column name="dep_package_tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </foreign-key>
+ <foreign-key name="dep_package_fk" deferrable="DEFERRED">
+ <column name="dep_package_tenant"/>
+ <column name="dep_package_name"/>
+ <column name="dep_package_version_epoch"/>
+ <column name="dep_package_version_canonical_upstream"/>
+ <column name="dep_package_version_canonical_release"/>
+ <column name="dep_package_version_revision"/>
+ <references table="package">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </foreign-key>
+ </add-table>
+ </changeset>
+
<model version="21">
<table name="tenant" kind="object">
<column name="id" type="TEXT" null="false"/>