Add missing db migrations for h2 and mariadb

This commit is contained in:
eikek 2021-11-20 15:24:07 +01:00
parent aecc689240
commit b79ac5fbad
2 changed files with 42 additions and 0 deletions

View File

@ -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";

View File

@ -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`;