Skip to content

Instantly share code, notes, and snippets.

@MgaMPKAy
Created March 20, 2012 17:31
Show Gist options
  • Save MgaMPKAy/2138408 to your computer and use it in GitHub Desktop.
Save MgaMPKAy/2138408 to your computer and use it in GitHub Desktop.
{-# 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