summaryrefslogtreecommitdiff
path: root/dbreset
diff options
context:
space:
mode:
authorquidtum <quidtum>2020-11-30 20:23:16 -0500
committerquidtum <quidtum>2020-12-06 20:09:56 -0500
commit38b8e7047b944a8f6ed41bea6bda1e7e3fe00259 (patch)
tree1dcf9e39d206b7cc4e3e4fff562f36b18863c548 /dbreset
init
Diffstat (limited to 'dbreset')
-rw-r--r--dbreset/Main.hs25
1 files changed, 25 insertions, 0 deletions
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 ()