aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbrep/build-extra.sql2
-rw-r--r--libbrep/build-package.hxx2
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/package.hxx4
-rw-r--r--libbrep/package.xml7
-rw-r--r--migrate/migrate.cxx23
7 files changed, 37 insertions, 5 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index 9ecbcb1..7b9fec5 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -49,7 +49,7 @@ CREATE FOREIGN TABLE build_package (
version_release TEXT NULL,
internal_repository_tenant TEXT NULL,
internal_repository_canonical_name TEXT NULL,
- buildable BOOLEAN NOT NULL)
+ buildable_ BOOLEAN NOT NULL)
SERVER package_server OPTIONS (table_name 'package');
-- The foreign table for the build_package object builds member (that is of a
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 702f937..ffa9d0b 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -96,6 +96,8 @@ namespace brep
#pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
+ #pragma db member(buildable) column("buildable_")
+
private:
friend class odb::access;
build_package () = default;
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index 83b30a8..a883fa0 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -25,7 +25,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 9
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 10, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 11, closed)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index bf8920b..f4ba6cb 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="11"/>
+
<changeset version="10">
<alter-table name="build">
<add-column name="completion_timestamp" type="BIGINT" null="false" default="0"/>
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 07bd2a0..f679c62 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 17
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 17, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 18, closed)
namespace brep
{
@@ -583,6 +583,8 @@ namespace brep
#pragma db member(other_repositories) \
id_column("") value_column("repository_") value_not_null
+ #pragma db member(buildable) column("buildable_")
+
// search_index
//
#pragma db member(search_index) virtual(weighted_text) null \
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 785ae0f..292cd05 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,11 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="18">
+ <alter-table name="package">
+ <add-column name="buildable_" type="BOOLEAN" null="false"/>
+ <drop-column name="buildable"/>
+ </alter-table>
+ </changeset>
+
<model version="17">
<table name="tenant" kind="object">
<column name="id" type="TEXT" null="false"/>
diff --git a/migrate/migrate.cxx b/migrate/migrate.cxx
index 81c4543..1577f1b 100644
--- a/migrate/migrate.cxx
+++ b/migrate/migrate.cxx
@@ -206,7 +206,6 @@ create (database& db, bool extra_only) const
// Register the data migration functions for the package database schema.
//
-#if 0
template <schema_version v>
using package_migration_entry_base =
data_migration_entry<v, LIBBREP_PACKAGE_SCHEMA_VERSION_BASE>;
@@ -218,11 +217,31 @@ struct package_migration_entry: package_migration_entry_base<v>
: package_migration_entry_base<v> (f, "package") {}
};
+// Migrate the package buildable member data while changing its type from
+// boolean to enumeration.
+
+// Note that changing the data member type is not automatically handled by the
+// migration machinery. Thus, we split the schema change into two steps,
+// delaying the second step until the next commit:
+//
+// - Rename the buildable data member column preserving its boolean type and
+// migrate the data copying it from the original column into the new
+// temporary column (package schema version 18). Note that the original
+// column is deleted at the end of the migration.
+//
+// - Change the buildable data member type to the buildable_status
+// enumeration, revert the column name and migrate the data by filling the
+// originally-named column based on the temporary column (package schema
+// version 19). Note that the temporary column is deleted at the end of the
+// migration.
+//
static const package_migration_entry<18>
package_migrate_v18 ([] (database& db)
{
+ // Copy the buildable flag values into the new temporary column.
+ //
+ db.execute ("UPDATE package SET buildable_ = buildable");
});
-#endif
// main() function
//