From f5dbeccc352b43ce9daa82e8bd97bc32773541b4 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Fri, 6 Oct 2023 23:43:22 +0200 Subject: [PATCH] WIP: String IDs --- .../create_entity_ids_table.sql | 10 ++++- procedures/initAutoIncrement.sql | 40 ------------------- 2 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 procedures/initAutoIncrement.sql diff --git a/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql b/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql index ddd1ad1..5b07ce8 100644 --- a/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql +++ b/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql @@ -5,6 +5,8 @@ DROP PROCEDURE IF EXISTS retrieveGroup; DROP PROCEDURE IF EXISTS getInfo; DROP PROCEDURE IF EXISTS getRole; DROP PROCEDURE IF EXISTS setPassword; +DROP PROCEDURE IF EXISTS initAutoIncrement; +DELETE FROM entities WHERE id=99; -- new entity_ids table @@ -17,4 +19,10 @@ CREATE TABLE `entity_ids` ( ) ENGINE=InnoDB; -- fill all existing entities into the new entity_ids table. -INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id>0 AND role!="DOMAIN"; +INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id>0 AND role!="DOMAIN" AND id!=50; + +ALTER TABLE transaction_log MODIFY COLUMN `entity_id` VARCHAR(255) NOT NULL; + +ALTER TABLE user_info DROP CONSTRAINT `subjects_ibfk_1`; +ALTER TABle user_info MODIFY COLUMN `entity` VARCHAR(255) DEFAULT NULL; +ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KEY (`entity`) REFERENCES `entity_ids` (`id`); diff --git a/procedures/initAutoIncrement.sql b/procedures/initAutoIncrement.sql deleted file mode 100644 index 54cb545..0000000 --- a/procedures/initAutoIncrement.sql +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ - -DROP PROCEDURE IF EXISTS db_5_0.initAutoIncrement; -delimiter // - -CREATE PROCEDURE db_5_0.initAutoIncrement() -BEGIN - - SELECT @max := MAX(entity_id)+ 1 FROM transaction_log; - IF @max IS NOT NULL THEN - SET @stmtStr = CONCAT('ALTER TABLE entities AUTO_INCREMENT=',@max); - PREPARE stmt FROM @stmtStr; - EXECUTE stmt; - DEALLOCATE PREPARE stmt; - END IF; - -END; -// -delimiter ; -- GitLab