aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/database.cxx126
-rw-r--r--bpkg/package.hxx2
-rw-r--r--bpkg/package.xml74
3 files changed, 25 insertions, 177 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index d96c53b..5754fae 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -61,132 +61,6 @@ namespace bpkg
template <odb::schema_version v>
using migration_entry = odb::data_migration_entry<v, DB_SCHEMA_VERSION_BASE>;
- static const migration_entry<8>
- migrate_v8 ([] (odb::database& db)
- {
- for (shared_ptr<repository> r: pointer_result (db.query<repository> ()))
- {
- if (!r->name.empty ()) // Non-root repository?
- {
- r->local = r->location.local ();
- db.update (r);
- }
- }
- });
-
- static const migration_entry<9>
- migrate_v9 ([] (odb::database& db)
- {
- // Add the unnamed self-link of the target type.
- //
- shared_ptr<configuration> sl (
- make_shared<configuration> (optional<string> (), "target"));
-
- db.persist (sl);
- db.execute (string ("UPDATE \"main\".selected_package_prerequisites ") +
- "SET configuration = '" + sl->uuid.string () + "'");
- });
-
- static const migration_entry<10>
- migrate_v10 ([] (odb::database& db)
- {
- // Create the multi-column index for the configuration and prerequisite
- // columns of the selected_package_prerequisites table.
- //
- db.execute (
- "CREATE INDEX "
- "\"main\".selected_package_prerequisites_configuration_prerequisite_i "
- "ON selected_package_prerequisites (configuration, prerequisite)");
- });
-
- static const migration_entry<12>
- migrate_v12 ([] (odb::database& d)
- {
- // Drop foreign key constraint for the prerequisite column of the
- // selected_package_prerequisites table.
- //
- // Note that since SQLite provides no API to drop constraints we will
- // rename the selected_package_prerequisites table, create the new table
- // without the constraint, and copy the data into the new table.
- //
- // Also note that we can only perform migration of the main database,
- // since dropping index and table in an attached database fails by some
- // reason with the SQLITE_LOCKED error. This, however, is probably ok
- // since the host and build system module configurations are already
- // created without this constraint and its highly unlikely to encounter an
- // already migrated (up to version 11) a linked target configuration.
- //
- database& db (static_cast<database&> (d));
-
- if (!db.main ())
- return;
-
- db.execute ("ALTER TABLE \"main\".\"selected_package_prerequisites\" "
- "RENAME TO \"selected_package_prerequisites_old\"");
-
- db.execute ("CREATE TABLE \"main\".\"selected_package_prerequisites\" (\n"
- " \"package\" TEXT NULL COLLATE NOCASE,\n"
- " \"configuration\" TEXT NULL,\n"
- " \"prerequisite\" TEXT NULL COLLATE NOCASE,\n"
- " \"min_version_epoch\" INTEGER NULL,\n"
- " \"min_version_canonical_upstream\" TEXT NULL,\n"
- " \"min_version_canonical_release\" TEXT NULL,\n"
- " \"min_version_revision\" INTEGER NULL,\n"
- " \"min_version_iteration\" INTEGER NULL,\n"
- " \"min_version_upstream\" TEXT NULL,\n"
- " \"min_version_release\" TEXT NULL,\n"
- " \"max_version_epoch\" INTEGER NULL,\n"
- " \"max_version_canonical_upstream\" TEXT NULL,\n"
- " \"max_version_canonical_release\" TEXT NULL,\n"
- " \"max_version_revision\" INTEGER NULL,\n"
- " \"max_version_iteration\" INTEGER NULL,\n"
- " \"max_version_upstream\" TEXT NULL,\n"
- " \"max_version_release\" TEXT NULL,\n"
- " \"min_open\" INTEGER NULL,\n"
- " \"max_open\" INTEGER NULL,\n"
- " CONSTRAINT \"package_fk\"\n"
- " FOREIGN KEY (\"package\")\n"
- " REFERENCES \"selected_package\" (\"name\")\n"
- " ON DELETE CASCADE)");
-
- db.execute ("INSERT INTO \"main\".\"selected_package_prerequisites\" "
- "SELECT "
- "\"package\", "
- "\"configuration\", "
- "\"prerequisite\", "
- "\"min_version_epoch\", "
- "\"min_version_canonical_upstream\", "
- "\"min_version_canonical_release\", "
- "\"min_version_revision\", "
- "\"min_version_iteration\", "
- "\"min_version_upstream\", "
- "\"min_version_release\", "
- "\"max_version_epoch\", "
- "\"max_version_canonical_upstream\", "
- "\"max_version_canonical_release\", "
- "\"max_version_revision\", "
- "\"max_version_iteration\", "
- "\"max_version_upstream\", "
- "\"max_version_release\", "
- "\"min_open\", "
- "\"max_open\" "
- "FROM \"main\".\"selected_package_prerequisites_old\"");
-
- db.execute ("DROP TABLE \"main\".\"selected_package_prerequisites_old\"");
-
- // Create the indexes after dropping the old table to make sure the old
- // indexes are also dropped to date.
- //
- db.execute ("CREATE INDEX "
- "\"main\".\"selected_package_prerequisites_package_i\"\n"
- " ON \"selected_package_prerequisites\" (\"package\")");
-
- db.execute (
- "CREATE INDEX "
- "\"main\".selected_package_prerequisites_configuration_prerequisite_i "
- "ON selected_package_prerequisites (configuration, prerequisite)");
- });
-
// @@ Since there is no proper support for dropping table columns not in
// SQLite prior to 3.35.5 nor in ODB, we will drop the
// available_package_dependency_alternatives.dep_* columns manually. We,
diff --git a/bpkg/package.hxx b/bpkg/package.hxx
index d7c9461..51f7219 100644
--- a/bpkg/package.hxx
+++ b/bpkg/package.hxx
@@ -25,7 +25,7 @@
// Used by the data migration entries.
//
-#define DB_SCHEMA_VERSION_BASE 7
+#define DB_SCHEMA_VERSION_BASE 12
#pragma db model version(DB_SCHEMA_VERSION_BASE, 20, closed)
diff --git a/bpkg/package.xml b/bpkg/package.xml
index 3fa1bc0..eafcaa8 100644
--- a/bpkg/package.xml
+++ b/bpkg/package.xml
@@ -177,50 +177,7 @@
</add-table>
</changeset>
- <changeset version="12"/>
-
- <changeset version="11">
- <alter-table name="main.available_package_tests">
- <add-column name="test_buildtime" type="INTEGER" null="true" default="0"/>
- </alter-table>
- </changeset>
-
- <changeset version="10"/>
-
- <changeset version="9">
- <add-table name="main.configuration" kind="object">
- <column name="id" type="INTEGER" null="true"/>
- <column name="uuid" type="TEXT" null="true"/>
- <column name="name" type="TEXT" null="true"/>
- <column name="type" type="TEXT" null="true"/>
- <column name="path" type="TEXT" null="true"/>
- <column name="explicit" type="INTEGER" null="true"/>
- <primary-key auto="true">
- <column name="id"/>
- </primary-key>
- <index name="configuration_uuid_i" type="UNIQUE">
- <column name="uuid"/>
- </index>
- <index name="configuration_name_i" type="UNIQUE">
- <column name="name"/>
- </index>
- <index name="configuration_path_i" type="UNIQUE">
- <column name="path"/>
- </index>
- </add-table>
- <alter-table name="main.selected_package_prerequisites">
- <add-column name="configuration" type="TEXT" null="true"/>
- <drop-foreign-key name="prerequisite_fk"/>
- </alter-table>
- </changeset>
-
- <changeset version="8">
- <alter-table name="main.repository">
- <add-column name="local" type="INTEGER" null="true"/>
- </alter-table>
- </changeset>
-
- <model version="7">
+ <model version="12">
<table name="main.repository_fragment" kind="object">
<column name="name" type="TEXT" null="true"/>
<column name="url" type="TEXT" null="true"/>
@@ -272,6 +229,7 @@
<column name="url" type="TEXT" null="true"/>
<column name="type" type="TEXT" null="true"/>
<column name="certificate" type="TEXT" null="true"/>
+ <column name="local" type="INTEGER" null="true"/>
<primary-key>
<column name="name"/>
</primary-key>
@@ -494,6 +452,7 @@
<column name="max_version_release" type="TEXT" null="true"/>
<column name="min_open" type="INTEGER" null="true"/>
<column name="max_open" type="INTEGER" null="true"/>
+ <column name="configuration" type="TEXT" null="true"/>
<foreign-key name="package_fk" on-delete="CASCADE">
<column name="package"/>
<references table="main.selected_package">
@@ -503,12 +462,6 @@
<index name="selected_package_prerequisites_package_i">
<column name="package"/>
</index>
- <foreign-key name="prerequisite_fk" deferrable="DEFERRED">
- <column name="prerequisite"/>
- <references table="main.selected_package">
- <column name="name"/>
- </references>
- </foreign-key>
</table>
<table name="main.certificate" kind="object">
<column name="id" type="TEXT" null="true"/>
@@ -548,6 +501,7 @@
<column name="test_min_open" type="INTEGER" null="true"/>
<column name="test_max_open" type="INTEGER" null="true"/>
<column name="test_type" type="TEXT" null="true"/>
+ <column name="test_buildtime" type="INTEGER" null="true" default="0"/>
<foreign-key name="object_id_fk" on-delete="CASCADE">
<column name="name"/>
<column name="version_epoch"/>
@@ -576,5 +530,25 @@
<column name="index"/>
</index>
</table>
+ <table name="main.configuration" kind="object">
+ <column name="id" type="INTEGER" null="true"/>
+ <column name="uuid" type="TEXT" null="true"/>
+ <column name="name" type="TEXT" null="true"/>
+ <column name="type" type="TEXT" null="true"/>
+ <column name="path" type="TEXT" null="true"/>
+ <column name="explicit" type="INTEGER" null="true"/>
+ <primary-key auto="true">
+ <column name="id"/>
+ </primary-key>
+ <index name="configuration_uuid_i" type="UNIQUE">
+ <column name="uuid"/>
+ </index>
+ <index name="configuration_name_i" type="UNIQUE">
+ <column name="name"/>
+ </index>
+ <index name="configuration_path_i" type="UNIQUE">
+ <column name="path"/>
+ </index>
+ </table>
</model>
</changelog>