2019-04-15 20:23:25 +00:00
{- # LANGUAGE DeriveGeneric # -}
2019-04-16 12:02:41 +00:00
{- # LANGUAGE OverloadedStrings # -}
2019-04-15 20:23:25 +00:00
module Model.Beverage where
import Data.Text as T
import Data.Time.Calendar ( Day )
2019-04-16 12:02:41 +00:00
import Data.Profunctor.Product ( p13 )
2019-04-15 20:23:25 +00:00
import Data.Aeson
import Data.Aeson.Types
2019-04-16 12:02:41 +00:00
import qualified Database.PostgreSQL.Simple as PGS
2019-04-15 20:23:25 +00:00
import GHC.Generics
import Opaleye as O
2019-04-16 12:02:41 +00:00
initBeverage :: PGS . Query
initBeverage = " create Table if not exists \ " beverage \ " (id serial primary key, ident varchar(128) not null, price integer not null, amount integer not null, vanish integer not null, ml integer not null, avatar integer, supplier integer, max_amount integer not null, total_bought integer not null, amount_per_crate integer not null, price_per_crate integer, art_nr varchar(128)) "
2019-04-15 20:23:25 +00:00
beverageTable :: Table
2019-04-16 12:02:41 +00:00
( Maybe ( Field SqlInt4 )
, Field SqlText
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
2019-04-15 20:23:25 +00:00
, FieldNullable SqlInt4
, FieldNullable SqlInt4
2019-04-16 12:02:41 +00:00
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
, FieldNullable SqlInt4
2019-04-15 20:23:25 +00:00
, FieldNullable SqlText
)
2019-04-16 12:02:41 +00:00
( Field SqlInt4
, Field SqlText
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
, FieldNullable SqlInt4
2019-04-15 20:23:25 +00:00
, FieldNullable SqlInt4
2019-04-16 12:02:41 +00:00
, Field SqlInt4
, Field SqlInt4
, Field SqlInt4
2019-04-15 20:23:25 +00:00
, FieldNullable SqlInt4
, FieldNullable SqlText
)
beverageTable = table " beverage " (
2019-04-16 12:02:41 +00:00
p13
( tableField " id "
, tableField " ident "
2019-04-15 20:23:25 +00:00
, tableField " price "
, tableField " amount "
, tableField " vanish "
, tableField " ml "
, tableField " avatar "
, tableField " supplier "
, tableField " max_amount "
, tableField " total_bought "
, tableField " amount_per_crate "
, tableField " price_per_crate "
, tableField " art_nr "
)
)