diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 12e9b2e7837da3cae36be30e5f54ce343f75f5f3..1ccadcc2665ec4b2c94dd7445760606331c24647 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,8 +62,11 @@ unittests: build-testenv: tags: [ cached-dind ] image: docker:19.03 + only: + - web + - triggers stage: setup - script: + script: - cd .docker - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY # use here general latest or specific branch latest... diff --git a/CHANGELOG.md b/CHANGELOG.md index e312119a9a430febc8ca4ced11de5498983f81c5..b473e497b44265663f7aa1cc203e9d9f5ac7ae07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### +* `retrieveEntity` does not return the columns `VersionSeconds` and + `VersionNanos` anymore. +* `get_version_history` returns two additional columns, `child_username` and + `child_realm`. * Added a `versioned` flag to the following procedures: * `applyBackReference` * `applyIDFilter` diff --git a/patches/patch20201124-4.0.0-rc2/patch.sh b/patches/patch20201124-4.0.0-rc2/patch.sh new file mode 100755 index 0000000000000000000000000000000000000000..5dab9326328a7e7c4d0eef88776438b0f9760fb7 --- /dev/null +++ b/patches/patch20201124-4.0.0-rc2/patch.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# ** 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 +# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> +# +# 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 +# +# Update mysql schema to version v4.0.0-rc1 +NEW_VERSION="v4.0.0-rc2" +OLD_VERSION="v4.0.0-rc1" + +if [ -z "$UTILSPATH" ]; then + UTILSPATH="../utils" +fi + +. $UTILSPATH/patch_header.sh $* + + +check_version $OLD_VERSION + +# nothing to do, just new implementations for the procedures + +update_version $NEW_VERSION + +success + diff --git a/procedures/entityVersioning.sql b/procedures/entityVersioning.sql index baf1e56f5fd0f3d64446df484602921f367255e2..0c4e9cbcedd777f745c76249eb4352894b840c94 100644 --- a/procedures/entityVersioning.sql +++ b/procedures/entityVersioning.sql @@ -330,7 +330,8 @@ END; DROP PROCEDURE IF EXISTS db_2_0.get_version_history // /** - * Select version timestamps of an entity. + * Select the complete transaction history of an entity (Who created which + * version and when). * * Parameters * ---------- @@ -339,8 +340,8 @@ DROP PROCEDURE IF EXISTS db_2_0.get_version_history // * * Selects * ------- - * Tuples (child, parent, child_seconds, child_nanos). `child` and `parent` are - * version IDs. + * 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( in EntityID INT UNSIGNED) @@ -349,7 +350,9 @@ BEGIN SELECT c.version AS child, NULL as parent, t.seconds AS child_seconds, - t.nanos AS child_nanos + t.nanos AS child_nanos, + t.username AS child_username, + t.realm AS child_realm FROM entity_version AS c INNER JOIN transactions as t ON ( c.srid = t.srid ) WHERE c.entity_id = EntityID @@ -363,7 +366,9 @@ BEGIN UNION SELECT c.version AS child, p.version AS parent, t.seconds AS child_seconds, - t.nanos AS child_nanos + t.nanos AS child_nanos, + t.username AS child_username, + t.realm AS child_realm FROM entity_version AS p INNER JOIN entity_version as c INNER JOIN transactions AS t diff --git a/procedures/retrieveEntity.sql b/procedures/retrieveEntity.sql index f74e6233af941ef3762647448e4285c4a5d26366..c1fc7de0199097cd1c476b4e6d7ab525f99baabe 100644 --- a/procedures/retrieveEntity.sql +++ b/procedures/retrieveEntity.sql @@ -43,6 +43,10 @@ drop procedure if exists db_2_0.retrieveEntity // * `HEAD` for the latest version or as `HEAD~n`, which retrieves the n-th * ancestor of `HEAD`. * + * ResultSet + * --------- + * Tuple of (Datatype, Collection, EntityID, EntityName, EntityDesc, + * EntityRole, FileSize, FilePath, FileHash, ACL, Version) */ create procedure db_2_0.retrieveEntity( in EntityID INT UNSIGNED, @@ -53,8 +57,6 @@ retrieveEntityBody: BEGIN DECLARE FileHash VARCHAR(255) DEFAULT NULL; DECLARE DatatypeID INT UNSIGNED DEFAULT NULL; DECLARE CollectionName VARCHAR(255) DEFAULT NULL; - DECLARE VersionSeconds BIGINT UNSIGNED DEFAULT NULL; - DECLARE VersionNanos INT(10) UNSIGNED DEFAULT NULL; DECLARE IsHead BOOLEAN DEFAULT TRUE; DECLARE IVersion INT UNSIGNED DEFAULT NULL; @@ -70,14 +72,6 @@ retrieveEntityBody: BEGIN SELECT get_head_version(EntityID) = Version INTO IsHead; END IF; - SELECT t.seconds, t.nanos - INTO VersionSeconds, VersionNanos - FROM entity_version AS e - INNER JOIN transactions AS t - ON ( e.srid = t.srid ) - WHERE e.entity_id = EntityID - AND e.version = Version; - IF IsHead IS FALSE THEN SET IVersion=get_iversion(EntityID, Version); @@ -136,9 +130,7 @@ retrieveEntityBody: BEGIN FilePath AS FilePath, FileHash AS FileHash, (SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL, - Version AS Version, - VersionSeconds AS VersionSeconds, - VersionNanos AS VersionNanos + Version AS Version FROM archive_entities AS e WHERE e.id = EntityID AND e._iversion = IVersion @@ -187,9 +179,7 @@ retrieveEntityBody: BEGIN FilePath AS FilePath, FileHash AS FileHash, (SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL, - Version AS Version, - VersionSeconds AS VersionSeconds, - VersionNanos AS VersionNanos + Version AS Version FROM entities e WHERE id = EntityID LIMIT 1; END; // diff --git a/tests/test_entity_versioning.sql b/tests/test_entity_versioning.sql index 0c5147c8dd4baab7cb2d323370ff2db8e18f3845..26efd8c029e9ad01f8966ddd687ed31f3c4a2b49 100644 --- a/tests/test_entity_versioning.sql +++ b/tests/test_entity_versioning.sql @@ -143,6 +143,9 @@ SELECT tap.eq(count(*), 1, "after updateEntity, one entity in archive_entities") FROM archive_entities; +-- TEST get_version_history +CALL get_version_history(@EntityID); + -- TEST retrieveEntity SELECT version INTO @x FROM entity_version