From 38b8e7047b944a8f6ed41bea6bda1e7e3fe00259 Mon Sep 17 00:00:00 2001 From: quidtum Date: Mon, 30 Nov 2020 20:23:16 -0500 Subject: init --- dbreset/Main.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dbreset/Main.hs (limited to 'dbreset') diff --git a/dbreset/Main.hs b/dbreset/Main.hs new file mode 100644 index 0000000..83d8cb8 --- /dev/null +++ b/dbreset/Main.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import Lib +import Database.SQLite.Simple +import System.Random.Stateful + +main :: IO () +main = withTx $ \conn -> do + execute_ conn "DROP TABLE IF EXISTS domains;" + execute_ conn "DROP TABLE IF EXISTS lines;" + execute_ conn "DROP TABLE IF EXISTS arrows;" + execute_ conn "CREATE TABLE domains (iden INTEGER PRIMARY KEY, name TEXT, ctime UTCTIME DEFAULT (datetime('now')));" + execute_ conn "CREATE UNIQUE INDEX idx_domains_name ON domains(name);" + execute_ conn "CREATE TABLE lines (iden INTEGER PRIMARY KEY, domain_iden INTEGER, txt TEXT, ctime UTCTIME DEFAULT (datetime('now')), color TEXT, FOREIGN KEY(domain_iden) REFERENCES domains(iden));" + execute_ conn "CREATE INDEX idx_lines_domain_iden ON lines(domain_iden);" + execute_ conn "CREATE TABLE arrows (domain_iden INTEGER, src INTEGER, dst INTEGER, FOREIGN KEY(domain_iden) REFERENCES domains(iden), FOREIGN KEY(src) REFERENCES lines(iden), FOREIGN KEY(dst) REFERENCES lines(iden));" + execute_ conn "CREATE INDEX idx_arrows_domain_iden ON arrows(domain_iden);" + execute_ conn "CREATE INDEX idx_arrows_src ON arrows(src);" + execute_ conn "CREATE INDEX idx_arrows_dst ON arrows(dst);" + g <- newStdGen >>= newIOGenM + graphSpec <- makeDefaultGraphSpec g + Lib.createDomain conn (DomainName "piazza") graphSpec + return () -- cgit v1.2.3