Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
d03e0973
Commit
d03e0973
authored
Sep 04, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB SCHEMA] adding hash_id column to nodes
parent
0bb02fc9
Pipeline
#1036
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
schema.sql
devops/postgres/schema.sql
+23
-3
Nodes.hs
src/Gargantext/Database/Admin/Trigger/Nodes.hs
+1
-0
No files found.
devops/postgres/schema.sql
View file @
d03e0973
...
...
@@ -23,6 +23,7 @@ ALTER TABLE public.auth_user OWNER TO gargantua;
-- TODO typename -> type_id
CREATE
TABLE
public
.
nodes
(
id
SERIAL
,
hash_id
CHARACTER
varying
(
66
)
DEFAULT
''
::
character
varying
NOT
NULL
,
typename
INTEGER
NOT
NULL
,
user_id
INTEGER
NOT
NULL
,
parent_id
INTEGER
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
...
...
@@ -151,9 +152,10 @@ CREATE INDEX ON public.nodes USING btree (user_id, typename, parent_id);
CREATE
INDEX
ON
public
.
nodes
USING
btree
(
id
,
typename
,
date
ASC
);
CREATE
INDEX
ON
public
.
nodes
USING
btree
(
id
,
typename
,
date
DESC
);
CREATE
INDEX
ON
public
.
nodes
USING
btree
(
typename
,
id
);
CREATE
UNIQUE
INDEX
ON
public
.
nodes
USING
btree
(((
hyperdata
->>
'uniqId'
::
text
)));
CREATE
UNIQUE
INDEX
ON
public
.
nodes
USING
btree
(((
hyperdata
->>
'uniqIdBdd'
::
text
)));
CREATE
UNIQUE
INDEX
ON
public
.
nodes
USING
btree
(
typename
,
parent_id
,
((
hyperdata
->>
'uniqId'
::
text
)));
CREATE
UNIQUE
INDEX
ON
public
.
nodes
USING
btree
(
hash_id
);
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqId'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqIdBdd'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (typename, parent_id, ((hyperdata ->> 'uniqId'::text)));
CREATE
UNIQUE
INDEX
ON
public
.
ngrams
(
terms
);
-- TEST GIN
CREATE
INDEX
ON
public
.
ngrams
USING
btree
(
id
,
terms
);
...
...
@@ -187,3 +189,21 @@ CREATE OR REPLACE function node_pos(int, int) returns bigint
--drop index node_by_pos;
create
index
node_by_pos
on
nodes
using
btree
(
node_pos
(
id
,
typename
));
-- Trigger to update hash of nodes
CREATE
EXTENSION
pgcrypto
;
CREATE
OR
REPLACE
FUNCTION
hash_update_nodes
()
RETURNS
trigger
AS
$$
BEGIN
IF
tg_op
=
'INSERT'
OR
tg_op
=
'UPDATE'
THEN
IF
NEW
.
hash_id
=
''
THEN
NEW
.
hash_id
=
digest
(
CONCAT
(
NEW
.
id
,
NEW
.
hyperdata
),
'sha256'
);
END
IF
;
RETURN
NEW
;
END
IF
;
END
$$
LANGUAGE
plpgsql
;
CREATE
TRIGGER
some_table_hash_update
BEFORE
INSERT
OR
UPDATE
ON
nodes
FOR
EACH
ROW
EXECUTE
PROCEDURE
hash_update_nodes
();
src/Gargantext/Database/Admin/Trigger/Nodes.hs
View file @
d03e0973
...
...
@@ -67,3 +67,4 @@ triggerSearchUpdate = execPGSQuery query ( nodeTypeId NodeDocument
|]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment