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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
4a80fa7b
Commit
4a80fa7b
authored
Jan 21, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MIGRATION] gargantext-upgrade can be used.
parent
cfbd39f8
Pipeline
#2382
passed with stage
in 33 minutes and 30 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
275 additions
and
45 deletions
+275
-45
Main.hs
bin/gargantext-upgrade/Main.hs
+208
-45
empty
devops/postgres/empty
+21
-0
nodes2contexts.sql
devops/postgres/upgrade/0.0.5/nodes2contexts.sql
+46
-0
No files found.
bin/gargantext-upgrade/Main.hs
View file @
4a80fa7b
This diff is collapsed.
Click to expand it.
devops/postgres/empty
0 → 100755
View file @
4a80fa7b
#!/bin/bash
# sudo su postgres
# postgresql://$USER:$PW@localhost/$DB
PW
=
"C8kdcUrAQy66U"
DB
=
"gargandb1"
USER
=
"gargantua"
#psql -c "CREATE USER \"${USER}\""
#psql -c "ALTER USER \"${USER}\" with PASSWORD '${PW}'"
psql
-c
"DROP DATABASE IF EXISTS
\"
${
DB
}
\"
"
createdb
"
${
DB
}
"
psql
-c
"ALTER DATABASE
\"
${
DB
}
\"
OWNER to
\"
${
USER
}
\"
"
devops/postgres/upgrade/0.0.5/nodes2contexts.sql
0 → 100644
View file @
4a80fa7b
-- to delete
-- DELETE FROM contexts;
-- WITH docs (id,hash_id,typename,user_id,parent_id,name,date,hyperdata, search)
WITH
docs
AS
(
SELECT
*
from
nodes
WHERE
nodes
.
typename
IN
(
4
,
41
)),
inserted
(
id
,
hash_id
)
AS
(
INSERT
INTO
contexts
(
hash_id
,
typename
,
user_id
,
parent_id
,
name
,
date
,
hyperdata
,
search
)
SELECT
d
.
hash_id
,
d
.
typename
,
d
.
user_id
,
NULL
,
d
.
name
,
d
.
date
,
d
.
hyperdata
,
search
FROM
docs
AS
d
RETURNING
contexts
.
id
,
contexts
.
hash_id
),
indexed
(
node_id
,
context_id
)
AS
(
SELECT
docs
.
id
,
inserted
.
id
from
inserted
JOIN
docs
on
docs
.
hash_id
=
inserted
.
hash_id
),
-- nodes_nodes -> nodes_contexts
nodes_contexts_query
AS
(
INSERT
INTO
nodes_contexts
(
node_id
,
context_id
,
score
,
category
)
SELECT
nn
.
node1_id
,
i
.
context_id
,
nn
.
score
,
nn
.
category
FROM
nodes_nodes
nn
JOIN
indexed
i
ON
i
.
node_id
=
nn
.
node2_id
),
-- nodes_nodes_ngrams -> contexts_nodes_ngrams
contexts_nodes_ngrams_query
AS
(
INSERT
INTO
context_node_ngrams
SELECT
i
.
context_id
,
nnn
.
node1_id
,
nnn
.
ngrams_id
,
nnn
.
ngrams_type
,
nnn
.
weight
FROM
node_node_ngrams
nnn
JOIN
indexed
i
ON
i
.
node_id
=
nnn
.
node2_id
),
---- nodes_nodes_ngrams2 -> contexts_nodes_ngrams2
context_node_ngrams2_query
AS
(
INSERT
INTO
context_node_ngrams2
SELECT
i
.
context_id
,
nnn2
.
nodengrams_id
,
nnn2
.
weight
FROM
node_node_ngrams2
nnn2
JOIN
indexed
i
ON
i
.
node_id
=
nnn2
.
node_id
)
-- WITH CASCADE it should update others tables
DELETE
FROM
nodes
n
USING
indexed
i
WHERE
i
.
node_id
=
n
.
id
;
UPDATE
contexts
SET
parent_id
=
id
;
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