Commit 7f48ce14 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DB] Schema update.

parent 6138b96b
...@@ -61,13 +61,15 @@ CREATE TABLE public.node_ngrams ( ...@@ -61,13 +61,15 @@ CREATE TABLE public.node_ngrams (
ALTER TABLE public.node_ngrams OWNER TO gargantua; ALTER TABLE public.node_ngrams OWNER TO gargantua;
CREATE TABLE public.node_node_ngrams_ngrams ( CREATE TABLE public.node_node_ngrams_ngrams (
node_id integer NOT NULL, node1_id integer NOT NULL,
node2_id integer NOT NULL,
node_ngrams1_id integer NOT NULL, node_ngrams1_id integer NOT NULL,
node_ngrams2_id integer NOT NULL, node_ngrams2_id integer NOT NULL,
FOREIGN KEY (node_id) REFERENCES public.nodes(id) ON DELETE CASCADE, FOREIGN KEY (node1_id) REFERENCES public.nodes(id) ON DELETE CASCADE,
FOREIGN KEY (node2_id) REFERENCES public.nodes(id) ON DELETE CASCADE,
FOREIGN KEY (node_ngrams1_id) REFERENCES public.node_ngrams(id) ON DELETE CASCADE, FOREIGN KEY (node_ngrams1_id) REFERENCES public.node_ngrams(id) ON DELETE CASCADE,
FOREIGN KEY (node_ngrams2_id) REFERENCES public.node_ngrams(id) ON DELETE CASCADE, FOREIGN KEY (node_ngrams2_id) REFERENCES public.node_ngrams(id) ON DELETE CASCADE,
PRIMARY KEY (node_id, node_ngrams1_id, node_ngrams2_id) PRIMARY KEY (node1_id, node2_id, node_ngrams1_id, node_ngrams2_id)
); );
ALTER TABLE public.node_node_ngrams_ngrams OWNER TO gargantua; ALTER TABLE public.node_node_ngrams_ngrams OWNER TO gargantua;
......
...@@ -77,8 +77,8 @@ flowList :: FlowCmdM env err m ...@@ -77,8 +77,8 @@ flowList :: FlowCmdM env err m
flowList lId ngs = do flowList lId ngs = do
printDebug "listId flowList" lId printDebug "listId flowList" lId
-- TODO save in database -- TODO save in database
r <- listInsertDb lId toNodeNgramsW (Map.toList ngs) _r <- listInsertDb lId toNodeNgramsW (Map.toList ngs)
printDebug "result " r -- printDebug "result " r
listInsert lId ngs listInsert lId ngs
--trace (show $ List.filter (\n -> _ne_ngrams n == "versatile") $ List.concat $ Map.elems ngs) $ listInsert lId ngs --trace (show $ List.filter (\n -> _ne_ngrams n == "versatile") $ List.concat $ Map.elems ngs) $ listInsert lId ngs
pure lId pure lId
......
...@@ -125,7 +125,7 @@ listInsertDb l f ngs = insertNodeNgrams (f l ngs) ...@@ -125,7 +125,7 @@ listInsertDb l f ngs = insertNodeNgrams (f l ngs)
insertNodeNgrams :: [NodeNgramsW] -> Cmd err [Returning] insertNodeNgrams :: [NodeNgramsW] -> Cmd err [Returning]
insertNodeNgrams nns = runPGSQuery query (PGS.Only $ Values fields nns') insertNodeNgrams nns = runPGSQuery query (PGS.Only $ Values fields nns')
where where
fields = map (\t-> QualifiedIdentifier Nothing t) [ "int4","int4","text","int4" fields = map (\t-> QualifiedIdentifier Nothing t) ["int4","int4","text","int4"
,"int4","int4","int4","int4" ,"int4","int4","int4","int4"
,"float8"] ,"float8"]
-- nns' :: [(Int, ListTypeId, NgramsText, NgramsTypeId ,NgramsField, NgramsTag, NgramsClass, Double)] -- nns' :: [(Int, ListTypeId, NgramsText, NgramsTypeId ,NgramsField, NgramsTag, NgramsClass, Double)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment