{-# 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 ()