Skip to content
Snippets Groups Projects
Select Git revision
  • 8b6d92dd92ecb2ce1508f7c89f0b87ef8f001ee2
  • main default protected
  • dev protected
  • f-linkahead-rename
  • f-real-id
  • f-filesystem-import
  • f-filesystem-link
  • f-filesystem-directory
  • f-filesystem-core
  • f-filesystem-cleanup
  • f-filesystem-main
  • f-name
  • keep_changes
  • f-permission-checks-2
  • f-mysql8-tests
  • f-retrieve-history
  • t-distinct-parents
  • v8.1.0
  • v8.0.0
  • v7.0.2
  • v7.0.1
  • v7.0.0
  • v6.0.1
  • v6.0.0
  • v5.0.0
  • v4.1.0
  • v4.0.0
  • v3.0
  • v2.0.30
29 results

create_entity_ids_table.sql

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    create_entity_ids_table.sql 1.06 KiB
    -- a little bit of house keeping
    DROP PROCEDURE IF EXISTS retrieveSubEntity;
    DROP PROCEDURE IF EXISTS retrieveDatatype;
    DROP PROCEDURE IF EXISTS retrieveGroup;
    
    -- new entity_ids table
    DROP TABLE IF EXISTS `entity_ids`;
    CREATE TABLE `entity_ids` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `internal_id` int(10) unsigned NOT NULL COMMENT 'Internal ID of an entity. This id is used internally in the *_data tables and elsewhere. This ID is never exposed via the CaosDB API.',
        PRIMARY KEY `entity_ids_pk` (`id`),
        CONSTRAINT `entity_ids_internal_id` FOREIGN KEY (`internal_id`) REFERENCES `entities` (`id`)
    ) 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;
    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.';