From b79ac5fbad1c0a6c0e60b20b8724c552266f6a38 Mon Sep 17 00:00:00 2001 From: eikek Date: Sat, 20 Nov 2021 15:24:07 +0100 Subject: [PATCH] Add missing db migrations for h2 and mariadb --- .../h2/V1.29.0__reset_classifier_file.sql | 21 +++++++++++++++++++ .../V1.29.0__reset_classifier_file.sql | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 modules/store/src/main/resources/db/migration/h2/V1.29.0__reset_classifier_file.sql create mode 100644 modules/store/src/main/resources/db/migration/mariadb/V1.29.0__reset_classifier_file.sql diff --git a/modules/store/src/main/resources/db/migration/h2/V1.29.0__reset_classifier_file.sql b/modules/store/src/main/resources/db/migration/h2/V1.29.0__reset_classifier_file.sql new file mode 100644 index 00000000..c947aff6 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/h2/V1.29.0__reset_classifier_file.sql @@ -0,0 +1,21 @@ +CREATE TEMPORARY TABLE "temp_file_ids" ( + cid varchar(254) not null, + file_id varchar(254) not null +); + +INSERT INTO "temp_file_ids" SELECT "cid", "file_id" FROM "classifier_model"; + +INSERT INTO "job" + SELECT random_uuid(), 'learn-classifier', cid, CONCAT('{"collective":"', cid, '"}'), + 'new classifier', now(), 'docspell-system', 0, 'waiting', 0, 0,null,null,null,null,null + FROM "classifier_setting"; + +DELETE FROM "classifier_model"; + +DELETE FROM "filemeta" +WHERE "file_id" in (SELECT "file_id" FROM "temp_file_ids"); + +DELETE FROM "filechunk" +WHERE "file_id" in (SELECT "file_id" FROM "temp_file_ids"); + +DROP TABLE "temp_file_ids"; diff --git a/modules/store/src/main/resources/db/migration/mariadb/V1.29.0__reset_classifier_file.sql b/modules/store/src/main/resources/db/migration/mariadb/V1.29.0__reset_classifier_file.sql new file mode 100644 index 00000000..a69ff398 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/mariadb/V1.29.0__reset_classifier_file.sql @@ -0,0 +1,21 @@ +CREATE TEMPORARY TABLE `temp_file_ids` ( + cid varchar(254) not null, + file_id varchar(254) not null +); + +INSERT INTO `temp_file_ids` SELECT `cid`, `file_id` FROM `classifier_model`; + +INSERT INTO `job` + SELECT md5(rand()), 'learn-classifier', cid, CONCAT('{"collective":"', cid, '"}'), + 'new classifier', now(), 'docspell-system', 0, 'waiting', 0, 0,null,null,null,null,null + FROM `classifier_setting`; + +DELETE FROM `classifier_model`; + +DELETE FROM `filemeta` +WHERE `file_id` in (SELECT `file_id` FROM `temp_file_ids`); + +DELETE FROM `filechunk` +WHERE `file_id` in (SELECT `file_id` FROM `temp_file_ids`); + +DROP TABLE `temp_file_ids`;