Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-mysqlbackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-mysqlbackend
Commits
7851224f
Verified
Commit
7851224f
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: filestorage refactoring
parent
6ab7d483
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
DRAFT: ENH: file system: core
Pipeline
#30970
failed
2 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
patches/patch20220110-6.0-SNAPSHOT/patch.sql
+15
-15
15 additions, 15 deletions
patches/patch20220110-6.0-SNAPSHOT/patch.sql
procedures/deleteEntity.sql
+1
-1
1 addition, 1 deletion
procedures/deleteEntity.sql
procedures/retrieveEntity.sql
+4
-4
4 additions, 4 deletions
procedures/retrieveEntity.sql
with
20 additions
and
20 deletions
patches/patch20220110-6.0-SNAPSHOT/patch.sql
+
15
−
15
View file @
7851224f
...
...
@@ -41,7 +41,7 @@ ALTER TABLE archive_files DROP COLUMN hash;
-- Add new fields to files table...
ALTER
TABLE
files
ADD
COLUMN
IF
NOT
EXISTS
(
hash_algorithm
VARBINARY
(
255
)
NULL
DEFAULT
"SHA-512"
,
parent_directory
INT
UNSIGNED
DEFAULT
NULL
,
--
parent_directory INT UNSIGNED DEFAULT NULL,
mimetype
VARBINARY
(
255
)
DEFAULT
NULL
,
file_storage_id
VARBINARY
(
255
)
NOT
NULL
DEFAULT
"DEFAULT"
,
file_key
VARBINARY
(
16000
)
DEFAULT
NULL
...
...
@@ -51,7 +51,7 @@ ALTER TABLE files ADD COLUMN IF NOT EXISTS (
ALTER
TABLE
archive_files
ADD
COLUMN
IF
NOT
EXISTS
(
checked_timestamp
BIGINT
NOT
NULL
DEFAULT
0
,
hash_algorithm
VARBINARY
(
255
)
NULL
DEFAULT
"SHA-512"
,
parent_directory
INT
UNSIGNED
DEFAULT
NULL
,
--
parent_directory INT UNSIGNED DEFAULT NULL,
mimetype
VARBINARY
(
255
)
DEFAULT
NULL
,
file_storage_id
VARBINARY
(
255
)
NOT
NULL
DEFAULT
"DEFAULT"
,
file_key
VARBINARY
(
16000
)
DEFAULT
NULL
...
...
@@ -60,15 +60,15 @@ ALTER TABLE archive_files ADD COLUMN IF NOT EXISTS (
-- no two files at the same path are allowed.
ALTER
TABLE
files
ADD
UNIQUE
(
`path`
);
-- directories cannot be deleted without deleting all the content first.
ALTER
TABLE
files
ADD
FOREIGN
KEY
(
parent_directory
)
REFERENCES
entities
(
id
);
ALTER
TABLE
archive_files
ADD
FOREIGN
KEY
(
parent_directory
)
REFERENCES
entities
(
id
)
ON
DELETE
CASCADE
;
--
ALTER TABLE files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id);
--
ALTER TABLE archive_files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id) ON DELETE CASCADE;
ALTER
TABLE
entities
MODIFY
COLUMN
`role`
enum
(
'RECORDTYPE'
,
'RECORD'
,
'FILE'
,
'DOMAIN'
,
'PROPERTY'
,
'DATATYPE'
,
'ROLE'
,
'QUERYTEMPLATE'
,
'DIRECTORY'
)
COLLATE
utf8_unicode_ci
NOT
NULL
;
--
ALTER TABLE entities MODIFY COLUMN `role` enum('RECORDTYPE','RECORD','FILE','DOMAIN','PROPERTY','DATATYPE','ROLE','QUERYTEMPLATE', 'DIRECTORY') COLLATE utf8_unicode_ci NOT NULL;
-- Add a new special role "DIRECTORY"
INSERT
IGNORE
INTO
entities
(
id
,
description
,
role
,
acl
)
VALUES
(
9
,
"The directory role."
,
"ROLE"
,
0
);
INSERT
IGNORE
INTO
name_data
(
domain_id
,
entity_id
,
property_id
,
value
,
status
,
pidx
)
VALUES
(
0
,
9
,
20
,
"DIRECTORY"
,
"FIX"
,
0
);
--
INSERT IGNORE INTO entities (id, description, role, acl) VALUES (9, "The directory role.", "ROLE", 0);
--
INSERT IGNORE INTO name_data (domain_id, entity_id, property_id, value, status, pidx) VALUES (0, 9, 20, "DIRECTORY", "FIX", 0);
-- In the default file storage back-end the key is just the path.
UPDATE
files
SET
file_key
=
path
;
...
...
@@ -79,8 +79,8 @@ ALTER TABLE files MODIFY COLUMN file_key VARBINARY(16000) NOT NULL;
ALTER
TABLE
archive_files
MODIFY
COLUMN
file_key
VARBINARY
(
16000
)
NOT
NULL
;
-- Size may be NULL for directories
ALTER
TABLE
files
MODIFY
COLUMN
size
BIGINT
UNSIGNED
NULL
DEFAULT
NULL
;
ALTER
TABLE
archive_files
MODIFY
COLUMN
size
BIGINT
UNSIGNED
NULL
DEFAULT
NULL
;
--
ALTER TABLE files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
--
ALTER TABLE archive_files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
-- More characters for long names
ALTER
TABLE
files
MODIFY
COLUMN
path
VARCHAR
(
16000
)
NOT
NULL
;
...
...
@@ -88,11 +88,11 @@ ALTER TABLE archive_files MODIFY COLUMN path VARCHAR(16000) NOT NULL;
-- Add a special nameless directory which is used as the root directory of the
-- internal file system.
INSERT
IGNORE
INTO
entities
(
id
,
description
,
role
,
acl
)
VALUES
(
51
,
"The root directory of the internal files system"
,
"DIRECTORY"
,
0
);
INSERT
IGNORE
INTO
files
(
file_id
,
path
,
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
,
parent_directory
)
VALUES
(
51
,
""
,
0
,
"inode/directory"
,
"DEFAULT"
,
""
,
NULL
);
--
INSERT IGNORE INTO entities (id, description, role, acl) VALUES (51, "The root directory of the internal files system", "DIRECTORY", 0);
--
INSERT IGNORE INTO files
--
(file_id, path, checked_timestamp, mimetype, file_storage_id,
--
file_key, parent_directory)
--
VALUES (51, "", 0, "inode/directory", "DEFAULT", "", NULL);
DROP
PROCEDURE
IF
EXISTS
_create_dirs
;
DELIMITER
//
...
...
@@ -186,7 +186,7 @@ END //
DELIMITER
;
CALL
_create_dirs
();
--
CALL _create_dirs();
-- not to be used after this patch has been applied.
-- DROP PROCEDURE _create_dirs;
This diff is collapsed.
Click to expand it.
procedures/deleteEntity.sql
+
1
−
1
View file @
7851224f
...
...
@@ -43,7 +43,7 @@ BEGIN
-- detele file properties
DELETE
FROM
files
where
file_id
=
EntityID
;
DELETE
FROM
files
where
parent_directory
=
EntityID
;
/*
DELETE FROM files where parent_directory=EntityID;
*/
-- delete datatype stuff
DELETE
FROM
data_type
...
...
This diff is collapsed.
Click to expand it.
procedures/retrieveEntity.sql
+
4
−
4
View file @
7851224f
...
...
@@ -55,7 +55,7 @@ create procedure db_5_0.retrieveEntity(
in
Version
VARBINARY
(
255
))
retrieveEntityBody
:
BEGIN
DECLARE
FilePath
VARCHAR
(
15920
)
DEFAULT
NULL
;
DECLARE
FileParentID
INT
UNSIGNED
DEFAULT
NULL
;
/*
DECLARE FileParentID INT UNSIGNED DEFAULT NULL;
*/
DECLARE
FileSize
BIGINT
UNSIGNED
DEFAULT
NULL
;
DECLARE
FileHash
VARCHAR
(
255
)
DEFAULT
NULL
;
DECLARE
FileHashAlgo
VARCHAR
(
255
)
DEFAULT
NULL
;
...
...
@@ -154,8 +154,8 @@ retrieveEntityBody: BEGIN
END
IF
;
END
IF
;
SELECT
path
,
parent_directory
,
size
,
hex
(
hash
),
hash_algorithm
,
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
INTO
FilePath
,
FileParentID
,
FileSize
,
FileHash
,
FileHashAlgo
,
FileHashChecked
,
FileMimetype
,
FileStorageID
,
FileKey
SELECT
path
,
/*
parent_directory,
*/
size
,
hex
(
hash
),
hash_algorithm
,
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
INTO
FilePath
,
/*
FileParentID,
*/
FileSize
,
FileHash
,
FileHashAlgo
,
FileHashChecked
,
FileMimetype
,
FileStorageID
,
FileKey
FROM
files
WHERE
file_id
=
EntityID
LIMIT
1
;
...
...
@@ -195,7 +195,7 @@ retrieveEntityBody: BEGIN
FileMimetype
as
FileMimetype
,
FileStorageID
as
FileStorageID
,
FileKey
as
FileKey
,
FileParentID
as
FileParentID
,
/*
FileParentID as FileParentID,
*/
(
SELECT
acl
FROM
entity_acl
AS
a
WHERE
a
.
id
=
e
.
acl
)
AS
ACL
,
Version
AS
Version
FROM
entities
e
WHERE
id
=
EntityID
LIMIT
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment