Skip to content
Snippets Groups Projects
Verified Commit f349f8dc authored by Timm Fitschen's avatar Timm Fitschen
Browse files

EHN: Add new base schema (db_5_0.sql) for installation

parent bfdcb015
No related branches found
No related tags found
2 merge requests!7Release v5.0.0,!6EHN: Add new base schema (db_5_0.sql) for installation
Pipeline #13711 failed
Showing
with 1034 additions and 385 deletions
......@@ -22,7 +22,7 @@
#
SHELL=/bin/bash
INSTALL_SQL_FILE=db_2_0.sql
INSTALL_SQL_FILE=db_5_0.sql
# The hostname, used by testing in the CI pipeline
SQL_HOST ?= mysql
......
/*
* ** 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
*/
#-- MySQL batch stack to create the CaosDB database structure, v2.0.1
#-- AUTHOR: Timm Fitschen (timm.fitschen@ds.mpg.de)
#-- DATE: 2015-10-22
#--
#--
#--
#-- *************
#-- Drop database
#-- *************
DROP DATABASE IF EXISTS db_2_0;
#-- ***************
#-- Create database
#-- ***************
CREATE DATABASE IF NOT EXISTS db_2_0 DEFAULT CHARSET=utf8 DEFAULT COLLATE=utf8_unicode_ci;
USE db_2_0;
#-- ***********************
#-- Create function version
#-- ***********************
CREATE FUNCTION CaosDBVersion() RETURNS VARCHAR(255) DETERMINISTIC
RETURN 'v2.0.1';
#-- ************************
#-- Create table entities
#-- ************************
CREATE TABLE IF NOT EXISTS entities (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier.',
name VARCHAR(255) NULL COMMENT 'Name of the entity.',
description VARCHAR(255) NULL COMMENT 'Description of the entity.',
role ENUM('RECORDTYPE', 'RECORD', 'FILE', 'DOMAIN', 'PROPERTY', 'USER', 'GROUP', 'UNIT', 'DATATYPE')
NULL COMMENT 'Role of the entity',
acl INT UNSIGNED NULL COMMENT 'Access Control List for the entity.'
#-- , CONSTRAINT `ent_acl_acl_id` FOREIGN KEY (`acl`) REFERENCES `acl` (`id`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS name_overrides (
domain_id INT UNSIGNED,
entity_id INT UNSIGNED,
name VARCHAR(255),
UNIQUE KEY (domain_id, entity_id),
CONSTRAINT `nameov_d_ent_id` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `nameov_e_ent_id` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- ************************************
#-- Create table is-a
#-- ************************************
CREATE TABLE IF NOT EXISTS isa (
child INT UNSIGNED NOT NULL COMMENT 'Child',
parent INT UNSIGNED NOT NULL COMMENT 'Parent',
type Enum('INHERITANCE', 'SUBTYPING')
NOT NULL COMMENT 'Type of is-a relation.',
UNIQUE KEY (child, parent),
CONSTRAINT `parent_entity` FOREIGN KEY (`parent`) REFERENCES `entities` (`id`),
CONSTRAINT `child_entity` FOREIGN KEY (`child`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- ***************************
#-- Create table reference_data
#-- ***************************
CREATE TABLE IF NOT EXISTS reference_data (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
property_id INT UNSIGNED NOT NULL COMMENT 'Property.',
value INT UNSIGNED NULL COMMENT 'Value.',
status Enum('OBLIGATORY', 'RECOMMENDED', 'SUGGESTED', 'FIX', 'REPLACEMENT')
NOT NULL COMMENT 'Status of this statement.',
pidx TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Index of the property.',
INDEX(entity_id,property_id),
CONSTRAINT `ref_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `ref_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `ref_property_id_entity` FOREIGN KEY (`property_id`) REFERENCES `entities` (`id`),
CONSTRAINT `ref_value_entity` FOREIGN KEY (`value`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- *************************
#-- Create table integer_data
#-- *************************
CREATE TABLE IF NOT EXISTS integer_data (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
property_id INT UNSIGNED NOT NULL COMMENT 'Property.',
value INT NULL COMMENT 'Value.',
status Enum('OBLIGATORY', 'RECOMMENDED', 'SUGGESTED', 'FIX', 'REPLACEMENT')
NOT NULL COMMENT 'Status of this statement.',
pidx TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Index of the property.',
INDEX(domain_id,entity_id),
CONSTRAINT `int_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `int_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `int_property_id_entity` FOREIGN KEY (`property_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- ************************
#-- Create table double_data
#-- ************************
CREATE TABLE IF NOT EXISTS double_data (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
property_id INT UNSIGNED NOT NULL COMMENT 'Property.',
value DOUBLE NULL COMMENT 'Value.',
status Enum('OBLIGATORY', 'RECOMMENDED', 'SUGGESTED', 'FIX', 'REPLACEMENT')
NOT NULL COMMENT 'Status of this statement.',
pidx TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Index of the property.',
INDEX(domain_id,entity_id),
CONSTRAINT `dou_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dou_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dou_property_id_entity` FOREIGN KEY (`property_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- **************************
#-- Create table datetime_data
#-- **************************
CREATE TABLE IF NOT EXISTS datetime_data (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
property_id INT UNSIGNED NOT NULL COMMENT 'Property.',
value DATETIME NULL COMMENT 'Value.',
status Enum('OBLIGATORY', 'RECOMMENDED', 'SUGGESTED', 'FIX', 'REPLACEMENT')
NOT NULL COMMENT 'Status of this statement.',
pidx TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Index of the property.',
INDEX(domain_id,entity_id),
CONSTRAINT `dat_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dat_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dat_property_id_entity` FOREIGN KEY (`property_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- **********************
#-- Create table text_data
#-- **********************
CREATE TABLE IF NOT EXISTS text_data (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
property_id INT UNSIGNED NOT NULL COMMENT 'Property.',
value TEXT NULL COMMENT 'Value.',
status Enum('OBLIGATORY', 'RECOMMENDED', 'SUGGESTED', 'FIX', 'REPLACEMENT')
NOT NULL COMMENT 'Status of this statement.',
pidx TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Index of the property.',
INDEX(domain_id,entity_id),
CONSTRAINT `str_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `str_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `str_property_id_entity` FOREIGN KEY (`property_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- **********************
#-- Create table data_type
#-- **********************
CREATE TABLE IF NOT EXISTS data_type (
domain_id INT UNSIGNED NOT NULL COMMENT 'Domain.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity.',
datatype INT UNSIGNED NOT NULL COMMENT 'Datatype.',
UNIQUE INDEX(domain_id,entity_id),
CONSTRAINT `dt_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dt_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `dt_datatype_id_entity` FOREIGN KEY (`datatype`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- *******************
#-- Create table files
#-- *******************
CREATE TABLE IF NOT EXISTS files (
file_id INT UNSIGNED NOT NULL PRIMARY KEY COMMENT 'The file\'s ID.',
path VARCHAR(255) NOT NULL COMMENT 'Directory of the file.',
size BIGINT UNSIGNED NOT NULL COMMENT 'Size in kB (oktet bytes).',
hash BINARY(64) NOT NULL COMMENT 'SHA-512 Hash of the file.',
CONSTRAINT `fil_file_id_entity` FOREIGN KEY (`file_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- ******************
#-- Create table passwords
#-- ******************
CREATE TABLE IF NOT EXISTS passwords (
entity_id INT UNSIGNED NOT NULL PRIMARY KEY COMMENT 'User ID.',
password VARCHAR(255) NOT NULL COMMENT 'Password.',
CONSTRAINT `use_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- *******************
#-- Create table groups
#-- *******************
CREATE TABLE IF NOT EXISTS groups (
user_id INT UNSIGNED NOT NULL,
group_id INT UNSIGNED NOT NULL,
UNIQUE KEY(user_id, group_id)
, CONSTRAINT `user_id_entities_id` FOREIGN KEY (`user_id`) REFERENCES `entities` (`id`)
, CONSTRAINT `group_id_entities_id` FOREIGN KEY (`group_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- ********************
#-- Create table history
#-- ********************
CREATE TABLE IF NOT EXISTS transaction_log (
transaction VARCHAR(255) NOT NULL COMMENT 'Transaction.',
user_id INT UNSIGNED NOT NULL COMMENT 'User.',
date INT NOT NULL COMMENT 'Date of transaction.',
time MEDIUMINT UNSIGNED NOT NULL COMMENT 'Time of transaction.',
ns INT UNSIGNED NULL COMMENT 'Nanosecond part of transaction time.',
entity_id INT UNSIGNED NOT NULL COMMENT 'Entity ID.',
INDEX (entity_id), INDEX (date, time)
) ENGINE=InnoDB;
#-- ******************
#-- Create table rules
#-- ******************
CREATE TABLE IF NOT EXISTS rules (
domain_id INT UNSIGNED NOT NULL,
entity_id INT UNSIGNED NOT NULL,
transaction ENUM('INSERT', 'RETRIEVE', 'UPDATE', 'DELETE') NOT NULL,
criterion VARCHAR(255) NOT NULL,
#--ENUM('UNIT_PRESENT', 'ROLE_PRESENT', 'NAME_PRESENT', 'DESC_PRESENT', 'REFID_PRESENT', 'REFID_VALID', 'REFID_ISA_PAR_REFID', 'PROP_PRESENT') NOT NULL,
modus ENUM('MUST', 'SHOULD', 'SHOULDNT', 'MUSTNOT') NOT NULL,
CONSTRAINT `rule_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`),
CONSTRAINT `rule_domain_id_entity` FOREIGN KEY (`domain_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB;
#-- magic stuff
ALTER TABLE entities AUTO_INCREMENT=100;
INSERT INTO entities (id, name, description, role, acl) VALUES (1,'DOMAIN', 'The default domain.', 'domain', 0);
UPDATE entities SET id=0 where name='domain';
INSERT INTO entities (id, name, description, role, acl) VALUES (1,'RECORDTYPE', 'The default recordtype.', 'recordtype', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (2,'RECORD', 'The default record.', 'record', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (3,'FILE', 'The default file.', 'file', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (4,'PROPERTY', 'The default property.', 'PROPERTY', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (5,'USER', 'The default user.', 'USER', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (6,'UNIT', 'The default unit.', 'UNIT', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (7,'DATATYPE', 'The default datatype.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (8,'GROUP', 'The default group.', 'GROUP', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (11,'REFERENCE', 'The default reference data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (12,'INTEGER', 'The default integer data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (13,'DOUBLE', 'The default double data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (14,'TEXT', 'The default text data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (15,'DATETIME', 'The default datetime data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (16,'TIMESPAN', 'The default timespan data type.', 'DATATYPE', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (17,'FILE', 'The default file reference data type.', 'DATATYPE', 0);
#--INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 17, 17);
#--INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 11, 11);
INSERT INTO entities (id, name, description, role, acl) VALUES (20,'name', 'Name of an entity', 'PROPERTY', 0);
INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 20, 14);
INSERT INTO entities (id, name, description, role, acl) VALUES (21,'unit', 'Unit of an entity.', 'PROPERTY', 0);
INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 21, 14);
INSERT INTO entities (id, name, description, role, acl) VALUES (22,'exponent', 'Unit prefix exponent of an entity.', 'PROPERTY', 0);
INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 22, 12);
INSERT INTO entities (id, name, description, role, acl) VALUES (24,'description', 'Description of an entity.', 'PROPERTY', 0);
INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 24, 14);
INSERT INTO entities (id, name, description, role, acl) VALUES (25,'refid', 'Refid of an entity.', 'PROPERTY', 0);
INSERT INTO data_type (domain_id, entity_id, datatype) VALUES (0, 25, 11);
#--INSERT INTO entities (id, name, description, role, acl) VALUES (23,'role', 'Role of an entity.', 'PROPERTY', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (50,'SQLITE', 'The SQLite file data type.', 'DATATYPE', 0);
#-- USER STUFF
INSERT INTO entities (id, name, description, role, acl) VALUES (98, 'heartdb', 'The anonymous user.', 'USER', 0);
INSERT INTO entities (id, name, description, role, acl) VALUES (99, 'administration', 'The admin users.', 'GROUP', 0);
INSERT INTO passwords (entity_id, password) VALUES (98, '37d7bd8a833261b4e4653644ee0a065f522b92b3738ca9ae2cb43a83844bf352c4a59c386a44965997a508c61988c9484c093775027425091d6d3d435c3c0e0c');
INSERT INTO passwords (entity_id, password) VALUES (99, '37d7bd8a833261b4e4653644ee0a065f522b92b3738ca9ae2cb43a83844bf352c4a59c386a44965997a508c61988c9484c093775027425091d6d3d435c3c0e0c');
This diff is collapsed.
......@@ -19,9 +19,9 @@
*/
-- remove unused procedures
DROP PROCEDURE IF EXISTS db_2_0.initNegationFilter;
DROP PROCEDURE IF EXISTS db_2_0.initConjunctionFilter;
DROP PROCEDURE IF EXISTS db_2_0.finishNegationFilter;
DROP PROCEDURE IF EXISTS initNegationFilter;
DROP PROCEDURE IF EXISTS initConjunctionFilter;
DROP PROCEDURE IF EXISTS finishNegationFilter;
ALTER TABLE archive_isa
ADD COLUMN `direct` BOOLEAN DEFAULT TRUE;
......@@ -35,10 +35,10 @@ EntityID : UNSIGNED
The ID of the Entity.
*/
DROP PROCEDURE IF EXISTS db_2_0.deleteEntity;
DROP PROCEDURE IF EXISTS db_5_0.deleteEntity;
delimiter //
CREATE PROCEDURE db_2_0.deleteEntity(in EntityID INT UNSIGNED)
CREATE PROCEDURE db_5_0.deleteEntity(in EntityID INT UNSIGNED)
BEGIN
-- detele file properties
......
......@@ -23,10 +23,10 @@
* ** end header
*/
DROP PROCEDURE IF EXISTS db_2_0.deleteEntityProperties;
DROP PROCEDURE IF EXISTS db_5_0.deleteEntityProperties;
delimiter //
CREATE PROCEDURE db_2_0.deleteEntityProperties(in EntityID INT UNSIGNED)
CREATE PROCEDURE db_5_0.deleteEntityProperties(in EntityID INT UNSIGNED)
BEGIN
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
......
......@@ -24,7 +24,7 @@
*/
SET GLOBAL log_bin_trust_function_creators = 1;
DROP PROCEDURE IF EXISTS db_2_0.deleteIsa;
DROP PROCEDURE IF EXISTS db_5_0.deleteIsa;
DELIMITER //
/* Delete "is a" relations from the given entity towards ancestors.
......@@ -41,7 +41,7 @@ Parameters
EntityID : UNSIGNED
Child entity for which all parental relations should be deleted.
*/
CREATE PROCEDURE db_2_0.deleteIsa(IN EntityID INT UNSIGNED)
CREATE PROCEDURE db_5_0.deleteIsa(IN EntityID INT UNSIGNED)
BEGIN
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
......
......@@ -22,9 +22,9 @@
*/
DROP PROCEDURE IF EXISTS db_2_0.entityACL;
DROP PROCEDURE IF EXISTS db_5_0.entityACL;
delimiter //
CREATE PROCEDURE db_2_0.entityACL(out ACLID INT UNSIGNED, in ACLSTR VARBINARY(65525))
CREATE PROCEDURE db_5_0.entityACL(out ACLID INT UNSIGNED, in ACLSTR VARBINARY(65525))
BEGIN
SELECT id INTO ACLID FROM entity_acl as t WHERE t.acl=ACLSTR LIMIT 1;
IF ACLID IS NULL THEN
......
......@@ -20,7 +20,7 @@
delimiter //
DROP PROCEDURE IF EXISTS db_2_0.insert_single_child_version //
DROP PROCEDURE IF EXISTS db_5_0.insert_single_child_version //
/**
* Creates a new version record in the `entity_version` table.
......@@ -42,7 +42,7 @@ DROP PROCEDURE IF EXISTS db_2_0.insert_single_child_version //
* The transaction ID which created this entity version (by inserting
* or updating an entity).
*/
CREATE PROCEDURE db_2_0.insert_single_child_version(
CREATE PROCEDURE db_5_0.insert_single_child_version(
in EntityID INT UNSIGNED,
in Hash VARBINARY(255),
in Version VARBINARY(255),
......@@ -85,7 +85,7 @@ BEGIN
END;
//
DROP PROCEDURE IF EXISTS db_2_0.delete_all_entity_versions //
DROP PROCEDURE IF EXISTS db_5_0.delete_all_entity_versions //
/**
* Remove all records in the entity_version table for the given entity.
......@@ -95,7 +95,7 @@ DROP PROCEDURE IF EXISTS db_2_0.delete_all_entity_versions //
* EntityID
* The id of the versioned entity.
*/
CREATE PROCEDURE db_2_0.delete_all_entity_versions(
CREATE PROCEDURE db_5_0.delete_all_entity_versions(
in EntityID INT UNSIGNED)
BEGIN
......@@ -104,7 +104,7 @@ BEGIN
END;
//
DROP FUNCTION IF EXISTS db_2_0.get_iversion //
DROP FUNCTION IF EXISTS db_5_0.get_iversion //
/**
* Get the internal version id (an integer) of the (API-)version id.
......@@ -120,7 +120,7 @@ DROP FUNCTION IF EXISTS db_2_0.get_iversion //
* -------
* The internal version id.
*/
CREATE FUNCTION db_2_0.get_iversion(
CREATE FUNCTION db_5_0.get_iversion(
EntityID INT UNSIGNED,
Version VARBINARY(255))
RETURNS INT UNSIGNED
......@@ -136,7 +136,7 @@ END;
//
DROP FUNCTION IF EXISTS db_2_0.get_primary_parent_version //
DROP FUNCTION IF EXISTS db_5_0.get_primary_parent_version //
/**
* Get the version ID of the primary parent (i.e. predecessor) of a version.
......@@ -152,7 +152,7 @@ DROP FUNCTION IF EXISTS db_2_0.get_primary_parent_version //
* -------
* The id of the given version's primary parent version.
*/
CREATE FUNCTION db_2_0.get_primary_parent_version(
CREATE FUNCTION db_5_0.get_primary_parent_version(
EntityID INT UNSIGNED,
Version VARBINARY(255))
RETURNS VARBINARY(255)
......@@ -170,7 +170,7 @@ END;
//
DROP FUNCTION IF EXISTS db_2_0.get_version_timestamp //
DROP FUNCTION IF EXISTS db_5_0.get_version_timestamp //
/**
* Get the timestamp of a version by retrieving the timestamp of the
* transaction which created the version.
......@@ -187,7 +187,7 @@ DROP FUNCTION IF EXISTS db_2_0.get_version_timestamp //
* The versions' timestamp in <seconds-since-epoch>.<nanoseconds> format.
* Note that the dot `.` here is not necessarily a decimal separator.
*/
CREATE FUNCTION db_2_0.get_version_timestamp(
CREATE FUNCTION db_5_0.get_version_timestamp(
EntityID INT UNSIGNED,
Version VARBINARY(255))
RETURNS VARCHAR(255)
......@@ -203,7 +203,7 @@ BEGIN
END;
//
DROP FUNCTION IF EXISTS db_2_0.get_head_version //
DROP FUNCTION IF EXISTS db_5_0.get_head_version //
/**
* Get the version id of the HEAD of an entity.
......@@ -217,7 +217,7 @@ DROP FUNCTION IF EXISTS db_2_0.get_head_version //
* -------
* The version id of the HEAD.
*/
CREATE FUNCTION db_2_0.get_head_version(
CREATE FUNCTION db_5_0.get_head_version(
EntityID INT UNSIGNED)
RETURNS VARBINARY(255)
READS SQL DATA
......@@ -226,7 +226,7 @@ BEGIN
END;
//
DROP FUNCTION IF EXISTS db_2_0._get_head_iversion //
DROP FUNCTION IF EXISTS db_5_0._get_head_iversion //
/**
* Get the _iversion number of the HEAD of an entity.
......@@ -240,7 +240,7 @@ DROP FUNCTION IF EXISTS db_2_0._get_head_iversion //
* -------
* The _iversion of the HEAD.
*/
CREATE FUNCTION db_2_0._get_head_iversion(
CREATE FUNCTION db_5_0._get_head_iversion(
EntityID INT UNSIGNED)
RETURNS INT UNSIGNED
READS SQL DATA
......@@ -259,7 +259,7 @@ BEGIN
END;
DROP FUNCTION IF EXISTS db_2_0.get_head_relative //
DROP FUNCTION IF EXISTS db_5_0.get_head_relative //
/**
* Get the id of a version which is specified relative to the HEAD of an
......@@ -278,7 +278,7 @@ DROP FUNCTION IF EXISTS db_2_0.get_head_relative //
* -------
* The version id of the HEAD.
*/
CREATE FUNCTION db_2_0.get_head_relative(
CREATE FUNCTION db_5_0.get_head_relative(
EntityID INT UNSIGNED,
Offset INT UNSIGNED)
RETURNS VARBINARY(255)
......@@ -298,7 +298,7 @@ BEGIN
END;
//
DROP FUNCTION IF EXISTS db_2_0._get_version //
DROP FUNCTION IF EXISTS db_5_0._get_version //
/**
* The inverse function of get_iversion. Resolves the version id.
*
......@@ -313,7 +313,7 @@ DROP FUNCTION IF EXISTS db_2_0._get_version //
* -------
* The version id.
*/
CREATE FUNCTION db_2_0._get_version(
CREATE FUNCTION db_5_0._get_version(
EntityID INT UNSIGNED,
IVersion INT UNSIGNED)
RETURNS VARBINARY(255)
......@@ -327,7 +327,7 @@ BEGIN
END;
//
DROP PROCEDURE IF EXISTS db_2_0.get_version_history //
DROP PROCEDURE IF EXISTS db_5_0.get_version_history //
/**
* Select the complete transaction history of an entity (Who created which
......@@ -343,7 +343,7 @@ DROP PROCEDURE IF EXISTS db_2_0.get_version_history //
* Tuples (child, parent, child_seconds, child_nanos, child_username,
* child_realm). `child` and `parent` are version IDs.
*/
CREATE PROCEDURE db_2_0.get_version_history(
CREATE PROCEDURE db_5_0.get_version_history(
in EntityID INT UNSIGNED)
BEGIN
-- retrieve root(s) (initial versions)
......
......@@ -23,10 +23,10 @@
DROP PROCEDURE IF EXISTS db_2_0.getDependentEntities;
DROP PROCEDURE IF EXISTS db_5_0.getDependentEntities;
delimiter //
CREATE PROCEDURE db_2_0.getDependentEntities(in EntityID INT UNSIGNED)
CREATE PROCEDURE db_5_0.getDependentEntities(in EntityID INT UNSIGNED)
BEGIN
DROP TEMPORARY TABLE IF EXISTS refering;
......
......@@ -21,9 +21,9 @@
* ** end header
*/
Drop Procedure if exists db_2_0.getFileIdByPath;
Drop Procedure if exists db_5_0.getFileIdByPath;
Delimiter //
Create Procedure db_2_0.getFileIdByPath (in FilePath VARCHAR(255))
Create Procedure db_5_0.getFileIdByPath (in FilePath VARCHAR(255))
BEGIN
Select file_id as FileID from files where path=FilePath LIMIT 1;
......
......@@ -21,4 +21,4 @@
* ** end header
*/
#-- old procedure.
Drop Procedure if exists db_2_0.getInfo;
Drop Procedure if exists db_5_0.getInfo;
......@@ -27,9 +27,9 @@
DROP PROCEDURE IF EXISTS db_2_0.getRole;
DROP PROCEDURE IF EXISTS db_5_0.getRole;
delimiter //
CREATE PROCEDURE db_2_0.getRole(in RoleName VARCHAR(255))
CREATE PROCEDURE db_5_0.getRole(in RoleName VARCHAR(255))
BEGIN
Select e.id INTO @RoleID from entities e where e.name=RoleName AND e.role=RoleName LIMIT 1;
......
......@@ -21,10 +21,10 @@
* ** end header
*/
DROP PROCEDURE IF EXISTS db_2_0.initAutoIncrement;
DROP PROCEDURE IF EXISTS db_5_0.initAutoIncrement;
delimiter //
CREATE PROCEDURE db_2_0.initAutoIncrement()
CREATE PROCEDURE db_5_0.initAutoIncrement()
BEGIN
SELECT @max := MAX(entity_id)+ 1 FROM transaction_log;
......
......@@ -24,7 +24,7 @@
*/
DROP PROCEDURE IF EXISTS db_2_0.insertEntity;
DROP PROCEDURE IF EXISTS db_5_0.insertEntity;
delimiter //
/* Insert an Entity
......@@ -46,7 +46,7 @@ Select
A tuple (EntityID, Version)
*/
CREATE PROCEDURE db_2_0.insertEntity(in EntityName VARCHAR(255), in EntityDesc TEXT, in EntityRole VARCHAR(255), in ACL VARBINARY(65525))
CREATE PROCEDURE db_5_0.insertEntity(in EntityName VARCHAR(255), in EntityDesc TEXT, in EntityRole VARCHAR(255), in ACL VARBINARY(65525))
BEGIN
DECLARE NewEntityID INT UNSIGNED DEFAULT NULL;
DECLARE NewACLID INT UNSIGNED DEFAULT NULL;
......
......@@ -23,9 +23,9 @@
* ** end header
*/
DROP PROCEDURE IF EXISTS db_2_0.insertEntityProperty;
DROP PROCEDURE IF EXISTS db_5_0.insertEntityProperty;
delimiter //
CREATE PROCEDURE db_2_0.insertEntityProperty(
CREATE PROCEDURE db_5_0.insertEntityProperty(
in DomainID INT UNSIGNED,
in EntityID INT UNSIGNED,
in PropertyID INT UNSIGNED,
......
......@@ -21,7 +21,7 @@
*
* ** end header
*/
DROP PROCEDURE IF EXISTS db_2_0.insertIsa;
DROP PROCEDURE IF EXISTS db_5_0.insertIsa;
DELIMITER //
/**
......@@ -39,7 +39,7 @@ DELIMITER //
* p : UNSIGNED
* The parent entity
*/
CREATE PROCEDURE db_2_0.insertIsa(IN c INT UNSIGNED, IN p INT UNSIGNED)
CREATE PROCEDURE db_5_0.insertIsa(IN c INT UNSIGNED, IN p INT UNSIGNED)
insert_is_a_proc: BEGIN
INSERT INTO isa_cache (child, parent, rpath) VALUES (c, p, c);
......
......@@ -21,10 +21,10 @@
* ** end header
*/
DROP PROCEDURE IF EXISTS db_2_0.insertLinCon;
DROP PROCEDURE IF EXISTS db_5_0.insertLinCon;
delimiter //
CREATE PROCEDURE db_2_0.insertLinCon(in signature_from BIGINT, in signature_to BIGINT, in a DECIMAL(65,30), in b_dividend BIGINT, in b_divisor BIGINT, in c DECIMAL(65,30))
CREATE PROCEDURE db_5_0.insertLinCon(in signature_from BIGINT, in signature_to BIGINT, in a DECIMAL(65,30), in b_dividend BIGINT, in b_divisor BIGINT, in c DECIMAL(65,30))
BEGIN
INSERT IGNORE INTO units_lin_con (signature_from, signature_to, a, b_dividend, b_divisor, c) VALUES (signature_from, signature_to, a, b_dividend, b_divisor, c);
......@@ -33,10 +33,10 @@ END;
//
delimiter ;
DROP PROCEDURE IF EXISTS db_2_0.deleteLinCon;
DROP PROCEDURE IF EXISTS db_5_0.deleteLinCon;
delimiter //
CREATE PROCEDURE db_2_0.deleteLinCon(in sig BIGINT)
CREATE PROCEDURE db_5_0.deleteLinCon(in sig BIGINT)
BEGIN
DELETE FROM units_lin_con WHERE signature_from=sig;
......@@ -45,10 +45,10 @@ END;
//
delimiter ;
DROP PROCEDURE IF EXISTS db_2_0.updateLinCon;
DROP PROCEDURE IF EXISTS db_5_0.updateLinCon;
delimiter //
CREATE PROCEDURE db_2_0.updateLinCon(in sig_from BIGINT, in sig_to BIGINT, in new_a DECIMAL(65,30), in new_b_dividend BIGINT, in new_b_divisor BIGINT, in new_c DECIMAL(65,30))
CREATE PROCEDURE db_5_0.updateLinCon(in sig_from BIGINT, in sig_to BIGINT, in new_a DECIMAL(65,30), in new_b_dividend BIGINT, in new_b_divisor BIGINT, in new_c DECIMAL(65,30))
BEGIN
UPDATE units_lin_con SET signature_to=sig_to, a=new_a, b_dividend=new_b_dividend, b_divisor=new_b_divisor, c=new_c where signature_from=sig_from;
......@@ -57,10 +57,10 @@ END;
delimiter ;
DROP PROCEDURE IF EXISTS db_2_0.cleanUpLinCon;
DROP PROCEDURE IF EXISTS db_5_0.cleanUpLinCon;
delimiter //
CREATE PROCEDURE db_2_0.cleanUpLinCon()
CREATE PROCEDURE db_5_0.cleanUpLinCon()
BEGIN
DELETE FROM units_lin_con WHERE NOT EXISTS (SELECT '1' FROM double_data WHERE unit_sig=signature_from) AND NOT EXISTS (SELECT '1' FROM integer_data WHERE unit_sig=signature_from);
......
......@@ -21,9 +21,9 @@
* ** end header
*/
Drop Procedure if exists db_2_0.insertUser;
Drop Procedure if exists db_5_0.insertUser;
Delimiter //
Create Procedure db_2_0.insertUser(in Name VARCHAR(255), in Password VARCHAR(255))
Create Procedure db_5_0.insertUser(in Name VARCHAR(255), in Password VARCHAR(255))
BEGIN
......
......@@ -22,10 +22,10 @@
*/
DROP PROCEDURE IF EXISTS db_2_0.isSubtype;
DROP PROCEDURE IF EXISTS db_5_0.isSubtype;
delimiter //
CREATE PROCEDURE db_2_0.isSubtype(in c INT UNSIGNED, in p INT UNSIGNED)
CREATE PROCEDURE db_5_0.isSubtype(in c INT UNSIGNED, in p INT UNSIGNED)
BEGIN
DECLARE ret BOOLEAN DEFAULT FALSE;
SELECT TRUE INTO ret FROM isa_cache AS i WHERE i.child=c AND i.parent=p LIMIT 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment