aboutsummaryrefslogtreecommitdiff
path: root/server/src/Thermoprint/Server/Database.hs
blob: 29732e1d147f2cde9559967a9feafdac7bb20fb2 (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
26
27
28
29
30
31
32
33
34
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE QuasiQuotes                #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE ExistentialQuantification  #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances          #-}

module Thermoprint.Server.Database
       ( Job(..), JobId
       , Draft(..), DraftId
       , migrateAll
       ) where

import Control.DeepSeq

import Thermoprint.API (Printout, DraftTitle, JobStatus)

import Database.Persist.TH
import Database.Persist.Sql (unSqlBackendKey)
import Database.Persist.Class (Key)

import Thermoprint.Server.Database.Instances

share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Job
    content Printout
Draft
    title DraftTitle Maybe
    content Printout
|]

instance NFData (Key Job) where
  rnf = rnf . unSqlBackendKey . unJobKey