Commit 86de65ad authored by Alexandre Delanoë's avatar Alexandre Delanoë

[UPGRADE] main functions

parent 92d85f76
......@@ -25,6 +25,7 @@ import Gargantext.Database.Query.Table.Node.UpdateOpaleye
import Gargantext.Database.Prelude (Cmd'', )
import Gargantext.Prelude
import System.Environment (getArgs)
import Prelude (getLine)
-- | PosTag
import Gargantext.Database.Action.Flow (indexAllDocumentsWithPosTag)
......@@ -34,10 +35,17 @@ main :: IO ()
main = do
[iniPath] <- getArgs
putStrLn "Manual method (for now):"
putStrLn "Use SQL script to upgrade your schema database with the script:"
putStrLn "psql gargandbV5 < ./devops/postgres/upgrade/0.0.2.6.sql"
putStrLn "Then press enter key when you are done"
_ok <- getLine
let
upgrade :: Cmd'' DevEnv GargError ()
upgrade = do
_ <- createTable_NgramsPostag
-- This method does not work for now
-- _ <- createTable_NgramsPostag
_ <- indexAllDocumentsWithPosTag
pure ()
......
CREATE TABLE public.ngrams_postag (
id SERIAL,
lang_id INTEGER,
algo_id INTEGER,
postag CHARACTER varying(5),
ngrams_id INTEGER NOT NULL,
lemm_id INTEGER NOT NULL,
score INTEGER DEFAULT 1 ::integer NOT NULL,
FOREIGN KEY (ngrams_id) REFERENCES public.ngrams(id) ON DELETE CASCADE,
FOREIGN KEY (lemm_id) REFERENCES public.ngrams(id) ON DELETE CASCADE
) ;
-- ALTER TABLE public.ngrams_postag OWNER TO gargantua;
CREATE UNIQUE INDEX ON public.ngrams_postag (lang_id,algo_id,postag,ngrams_id,lemm_id);
......@@ -180,8 +180,9 @@ querySelectLems = [sql|
|]
-- | Insert Table
createTable_NgramsPostag :: Cmd err [(Form, Lem)]
createTable_NgramsPostag = runPGSQuery_ queryCreateTable
createTable_NgramsPostag :: Cmd err [Int]
createTable_NgramsPostag = map (\(PGS.Only a) -> a)
<$> runPGSQuery_ queryCreateTable
where
queryCreateTable :: PGS.Query
queryCreateTable = [sql|
......@@ -196,7 +197,7 @@ createTable_NgramsPostag = runPGSQuery_ queryCreateTable
score INTEGER DEFAULT 1 ::integer NOT NULL,
FOREIGN KEY (ngrams_id) REFERENCES public.ngrams(id) ON DELETE CASCADE,
FOREIGN KEY (lemm_id) REFERENCES public.ngrams(id) ON DELETE CASCADE
);
) ;
-- ALTER TABLE public.ngrams_postag OWNER TO gargantua;
CREATE UNIQUE INDEX ON public.ngrams_postag (lang_id,algo_id,postag,ngrams_id,lemm_id);
......
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