From 450b012280e077e6f32a7963c32ef951e2e7ce65 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 22 Dec 2022 12:55:42 +0100
Subject: [PATCH] WIP: external ids

---
 .../create_entity_ids_table.sql               |  7 -------
 .../patch.sh                                  |  6 +++---
 tests/test_autotap.sql                        | 21 -------------------
 tests/test_entity_versioning.sql              |  1 +
 4 files changed, 4 insertions(+), 31 deletions(-)
 rename patches/{patch20221122-5.0.1 => patch20221122-6.0-SNAPSHOT}/create_entity_ids_table.sql (71%)
 rename patches/{patch20221122-5.0.1 => patch20221122-6.0-SNAPSHOT}/patch.sh (92%)

diff --git a/patches/patch20221122-5.0.1/create_entity_ids_table.sql b/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql
similarity index 71%
rename from patches/patch20221122-5.0.1/create_entity_ids_table.sql
rename to patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql
index a60356d..0f58ba6 100644
--- a/patches/patch20221122-5.0.1/create_entity_ids_table.sql
+++ b/patches/patch20221122-6.0-SNAPSHOT/create_entity_ids_table.sql
@@ -21,10 +21,3 @@ INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id>0;
 INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id=0;
 UPDATE entity_ids SET id = internal_id;
 -- ALTER TABLE entity_ids CHANGE id id int(10) unsigned NOT NULL AUTO_INCREMENT  COMMENT 'External ID of an entity. This is the id of an entity which is exposed via the CaosDB API.';
-
-ALTER TABLE null_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
-ALTER TABLE text_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
-ALTER TABLE double_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
-ALTER TABLE integer_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
-ALTER TABLE reference_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
-ALTER TABLE enum_data CHANGE property_id property_id INT UNSIGNED NOT NULL;
diff --git a/patches/patch20221122-5.0.1/patch.sh b/patches/patch20221122-6.0-SNAPSHOT/patch.sh
similarity index 92%
rename from patches/patch20221122-5.0.1/patch.sh
rename to patches/patch20221122-6.0-SNAPSHOT/patch.sh
index ca2fb6a..7348ac0 100755
--- a/patches/patch20221122-5.0.1/patch.sh
+++ b/patches/patch20221122-6.0-SNAPSHOT/patch.sh
@@ -22,7 +22,7 @@
 # Update mysql schema to version v5.0.0
 # Drop the 'rules' table.
 
-NEW_VERSION="v5.0.1"
+NEW_VERSION="v6.0.0-SNAPSHOT-EXTIDS"
 OLD_VERSION="v5.0.0"
 
 if [ -z "$UTILSPATH" ]; then
@@ -31,11 +31,11 @@ fi
 
 . $UTILSPATH/patch_header.sh $*
 
-# check_version $OLD_VERSION
+check_version $OLD_VERSION
 
 mysql_execute_file $PATCH_DIR/create_entity_ids_table.sql
 
-# update_version $NEW_VERSION
+update_version $NEW_VERSION
 
 success
 
diff --git a/tests/test_autotap.sql b/tests/test_autotap.sql
index ebec730..9f77a59 100644
--- a/tests/test_autotap.sql
+++ b/tests/test_autotap.sql
@@ -2509,13 +2509,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getFileIdByPa
 SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getFileIdByPath','DEFINER','');
 SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getFileIdByPath','CONTAINS SQL','');
 
--- PROCEDURES _caosdb_schema_unit_tests.getRole
-
-SELECT tap.has_procedure('_caosdb_schema_unit_tests','getRole','');
-SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getRole','NO','');
-SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getRole','DEFINER','');
-SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getRole','CONTAINS SQL','');
-
 -- PROCEDURES _caosdb_schema_unit_tests.initAutoIncrement
 
 SELECT tap.has_procedure('_caosdb_schema_unit_tests','initAutoIncrement','');
@@ -2677,13 +2670,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','registerTempT
 SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','registerTempTableName','DEFINER','');
 SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','registerTempTableName','CONTAINS SQL','');
 
--- PROCEDURES _caosdb_schema_unit_tests.retrieveDatatype
-
-SELECT tap.has_procedure('_caosdb_schema_unit_tests','retrieveDatatype','');
-SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','retrieveDatatype','NO','');
-SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','retrieveDatatype','DEFINER','');
-SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','retrieveDatatype','CONTAINS SQL','');
-
 -- PROCEDURES _caosdb_schema_unit_tests.retrieveEntityParents
 
 SELECT tap.has_procedure('_caosdb_schema_unit_tests','retrieveEntityParents','');
@@ -2691,13 +2677,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','retrieveEntit
 SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','retrieveEntityParents','DEFINER','');
 SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','retrieveEntityParents','CONTAINS SQL','');
 
--- PROCEDURES _caosdb_schema_unit_tests.setPassword
-
-SELECT tap.has_procedure('_caosdb_schema_unit_tests','setPassword','');
-SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','setPassword','NO','');
-SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','setPassword','DEFINER','');
-SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','setPassword','CONTAINS SQL','');
-
 -- PROCEDURES _caosdb_schema_unit_tests.insertIsa
 
 SELECT tap.has_procedure('_caosdb_schema_unit_tests','insertIsa','');
diff --git a/tests/test_entity_versioning.sql b/tests/test_entity_versioning.sql
index 26efd8c..de4c649 100644
--- a/tests/test_entity_versioning.sql
+++ b/tests/test_entity_versioning.sql
@@ -95,6 +95,7 @@ SELECT tap.eq(@x, 0, "no versions there any more");
 
 -- TEARDOWN clean up
 DELETE FROM name_data WHERE entity_id > 99;
+DELETE FROM entity_ids WHERE internal_id > 99;
 DELETE FROM entities WHERE id > 99;
 
 -- #####################################################################
-- 
GitLab