Created
March 20, 2012 17:31
-
-
Save MgaMPKAy/2138408 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies, QuasiQuotes, TemplateHaskell #-} | |
{-# LANGUAGE MultiParamTypeClasses, OverloadedStrings #-} | |
{-# LANGUAGE GADTs, FlexibleContexts #-} | |
import Yesod | |
import Database.Persist | |
import Database.Persist.Sqlite | |
import Database.Persist.TH | |
import Data.Time | |
data LessonChoosing = LessonChoosing | |
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist| | |
Teacher | |
info String | |
Student | |
info String | |
Final | |
lessonName String | |
name String | |
teacher TeacherId | |
type String | |
origin String | |
maxSelect Int default=8 | |
selected Int default=0 | |
year Int | |
term Int | |
time UTCTime default=now | |
TeacherFinal | |
teacher TeacherId | |
final FinalId | |
UniqueTF teacher final | |
StudentFinal | |
student StudentId | |
final FinalId | |
comfirmed Bool | |
UniqueSF student final | |
|] | |
main = withSqliteConn "db.sql" $ runSqlConn $ do | |
runMigration migrateAll | |
s1 <- insert $ Student "StudentA" | |
s2 <- insert $ Student "StudentB" | |
s <- get s1 | |
liftIO $ print s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment