blob: 1e0168088eb074f71f1bf497456037ef38a576b7 (
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
35
36
37
38
39
|
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
module Thermoprint.Server.Database
( Job(..), JobId
, Draft(..), DraftId
, Key(..)
, migrateAll
, castId'
) where
import Control.DeepSeq
import Thermoprint.API (Printout, DraftTitle, JobStatus, castId)
import Database.Persist.TH
import Database.Persist.Sql (unSqlBackendKey, SqlBackend)
import Database.Persist.Class (Key, BackendKey)
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
castId' :: Enum b => BackendKey SqlBackend -> b
castId' = castId . unSqlBackendKey
|