From ff4120eafcd5d2bcc92eac530692db389a211db7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 8 Jul 2024 20:27:23 +0300 Subject: Drop all database migrations to be backward compatible with 0.16.0 and above (two minor versions behind) --- bpkg/buildfile | 3 - bpkg/database.cxx | 142 +--------------- bpkg/package.hxx | 2 +- bpkg/package.xml | 489 ++++++++++++++++++++++-------------------------------- 4 files changed, 205 insertions(+), 431 deletions(-) diff --git a/bpkg/buildfile b/bpkg/buildfile index e91d0cb..0646f22 100644 --- a/bpkg/buildfile +++ b/bpkg/buildfile @@ -15,9 +15,6 @@ import libs = build2%lib{build2} for m: bash bin c cc cli cxx in version import libs += build2%lib{build2-$m} -# @@ TMP we require libsqlite3 to be interface dependency of libbutl-odb only -# for the database migrations to schema versions 13 and 14. -# import libs += libbpkg%lib{bpkg} import libs += libbutl%lib{butl} import libs += libbutl%lib{butl-odb} diff --git a/bpkg/database.cxx b/bpkg/database.cxx index 65e3af8..51bcd7f 100644 --- a/bpkg/database.cxx +++ b/bpkg/database.cxx @@ -3,8 +3,6 @@ #include -#include // @@ TMP sqlite3_libversion_number() - #include #include @@ -58,99 +56,15 @@ namespace bpkg // NOTE: remember to qualify table/index names with \"main\". if using // native statements. // +#if 0 template using migration_entry = odb::data_migration_entry; - // @@ 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, - // however, cannot do it here since ODB will try to set the dropped - // column values to NULL at the end of migration. Thus, we will do it - // ad hoc after the below schema_catalog::migrate() call. - // - // NOTE: remove the mentioned ad hoc migration when removing this - // function. - // - static const migration_entry<13> - migrate_v13 ([] (odb::database& db) - { - // Note that - // available_package_dependency_alternative_dependencies.alternative_index - // is copied from available_package_dependency_alternatives.index and - // available_package_dependency_alternative_dependencies.index is set to 0. - // - db.execute ( - "INSERT INTO \"main\".\"available_package_dependency_alternative_dependencies\" " - "(\"name\", " - "\"version_epoch\", " - "\"version_canonical_upstream\", " - "\"version_canonical_release\", " - "\"version_revision\", " - "\"version_iteration\", " - "\"dependency_index\", " - "\"alternative_index\", " - "\"index\", " - "\"dep_name\", " - "\"dep_min_version_epoch\", " - "\"dep_min_version_canonical_upstream\", " - "\"dep_min_version_canonical_release\", " - "\"dep_min_version_revision\", " - "\"dep_min_version_iteration\", " - "\"dep_min_version_upstream\", " - "\"dep_min_version_release\", " - "\"dep_max_version_epoch\", " - "\"dep_max_version_canonical_upstream\", " - "\"dep_max_version_canonical_release\", " - "\"dep_max_version_revision\", " - "\"dep_max_version_iteration\", " - "\"dep_max_version_upstream\", " - "\"dep_max_version_release\", " - "\"dep_min_open\", " - "\"dep_max_open\") " - "SELECT " - "\"name\", " - "\"version_epoch\", " - "\"version_canonical_upstream\", " - "\"version_canonical_release\", " - "\"version_revision\", " - "\"version_iteration\", " - "\"dependency_index\", " - "\"index\", " - "0, " - "\"dep_name\", " - "\"dep_min_version_epoch\", " - "\"dep_min_version_canonical_upstream\", " - "\"dep_min_version_canonical_release\", " - "\"dep_min_version_revision\", " - "\"dep_min_version_iteration\", " - "\"dep_min_version_upstream\", " - "\"dep_min_version_release\", " - "\"dep_max_version_epoch\", " - "\"dep_max_version_canonical_upstream\", " - "\"dep_max_version_canonical_release\", " - "\"dep_max_version_revision\", " - "\"dep_max_version_iteration\", " - "\"dep_max_version_upstream\", " - "\"dep_max_version_release\", " - "\"dep_min_open\", " - "\"dep_max_open\" " - "FROM \"main\".\"available_package_dependency_alternatives\""); - }); - - // @@ 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_dependencies.conditional column manually. We, - // however, cannot do it here since ODB will try to set the dropped - // column values to NULL at the end of migration. Thus, we will do it - // ad hoc after the below schema_catalog::migrate() call. - // - // NOTE: remove the mentioned ad hoc migration when removing this - // function. - // - static const migration_entry<14> - migrate_v14 ([] (odb::database&) + static const migration_entry<27> + migrate_v27 ([] (odb::database&) { }); +#endif static inline path cfg_path (const dir_path& d, bool create) @@ -454,54 +368,6 @@ namespace bpkg // schema_catalog::migrate (*this); - // Note that the potential data corruption with `DROP COLUMN` is fixed - // in 3.35.5. - // - // @@ TMP Get rid of manual column dropping when ODB starts supporting - // that properly. Not doing so will result in failure of the below - // queries. - // - if (sqlite3_libversion_number () >= 3035005) - { - auto drop = [this] (const char* table, const char* column) - { - execute (std::string ("ALTER TABLE \"main\".") + table + - " DROP COLUMN \"" + column + '"'); - }; - - // @@ TMP See migrate_v13() for details. - // - if (sv < 13) - { - const char* cs[] = {"dep_name", - "dep_min_version_epoch", - "dep_min_version_canonical_upstream", - "dep_min_version_canonical_release", - "dep_min_version_revision", - "dep_min_version_iteration", - "dep_min_version_upstream", - "dep_min_version_release", - "dep_max_version_epoch", - "dep_max_version_canonical_upstream", - "dep_max_version_canonical_release", - "dep_max_version_revision", - "dep_max_version_iteration", - "dep_max_version_upstream", - "dep_max_version_release", - "dep_min_open", - "dep_max_open", - nullptr}; - - for (const char** c (cs); *c != nullptr; ++c) - drop ("available_package_dependency_alternatives", *c); - } - - // @@ TMP See migrate_v14() for details. - // - if (sv < 14) - drop ("available_package_dependencies", "conditional"); - } - for (auto& c: query (odb::query::id != 0)) { dir_path d (c.effective_path (config)); diff --git a/bpkg/package.hxx b/bpkg/package.hxx index 400519a..8fe448c 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -30,7 +30,7 @@ // migration is no longer supported (i.e., the current and base schema // versions are the same). // -#define DB_SCHEMA_VERSION_BASE 12 +#define DB_SCHEMA_VERSION_BASE 23 #pragma db model version(DB_SCHEMA_VERSION_BASE, 26, closed) diff --git a/bpkg/package.xml b/bpkg/package.xml index 8020ff3..f001712 100644 --- a/bpkg/package.xml +++ b/bpkg/package.xml @@ -35,277 +35,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -396,6 +126,12 @@ + + + + + + @@ -453,7 +189,6 @@ - @@ -494,23 +229,11 @@ - - - - - - - - - - - - - - - - - + + + + + @@ -557,6 +280,7 @@ + @@ -581,6 +305,8 @@ + + @@ -630,6 +356,7 @@ + @@ -678,5 +405,189 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-- cgit v1.1