blob: 83d8cb8223666836c6a5c4f929567de1cba61f47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 ()
|