aboutsummaryrefslogtreecommitdiff
path: root/migrate/migrate.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-01 21:50:16 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-05 12:55:51 +0300
commitd1662abccb91be4844efc1508ff8b0427019a27c (patch)
tree6a0a8e1f86b51f97af67e2b65d20898cc42218b2 /migrate/migrate.cxx
parentca708a3f172e2f0ffab8638087b3e478de06b996 (diff)
Prepare to replacing package buildable flag with enumeration
Note that changing the data member type is not automatically handled by the ODB migration machinery. Thus, we split the schema change into two steps, with this commit implementing the first step (see migrate/migrate.cxx for details).
Diffstat (limited to 'migrate/migrate.cxx')
-rw-r--r--migrate/migrate.cxx23
1 files changed, 21 insertions, 2 deletions
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
//