mateamt/src/Model/Amount.hs

44 lines
1 KiB
Haskell
Raw Normal View History

2019-07-21 12:53:00 +00:00
{-# LANGUAGE OverloadedStrings #-}
2019-07-21 12:40:49 +00:00
module Model.Amount where
import Data.Profunctor.Product (p5)
import qualified Database.PostgreSQL.Simple as PGS
import Opaleye as O
import Opaleye.Constant as C
initAmount :: PGS.Query
2019-07-21 14:05:31 +00:00
initAmount = mconcat
2019-07-21 12:40:49 +00:00
[ "CREATE TABLE IF NOT EXISTS \"amount\" ("
, "amounts_product_id BIGINT NOT NULL REFERENCES product ON DELETE CASCADE,"
, "amounts_timestamp TIMESTAMPTZ NOT NULL,"
, "amounts_amount INTEGER NOT NULL,"
, "amounts_price INTEGER NOT NULL,"
, "amounts_verified BOOLEAN NOT NULL,"
, "PRIMARY KEY (product_id, timestamp)"
]
amountTable :: Table
( Field SqlInt4
, Field SqlDate
, Field SqlInt4
, Field SqlInt4
, Field SqlBool
)
( Field SqlInt4
, Field SqlDate
, Field SqlInt4
, Field SqlInt4
, Field SqlBool
)
amountTable = table "amount" (
p5
( tableField "amonnts_product_id"
, tableField "amounts_timestamp"
, tableField "amounts_amount"
, tableField "amounts_price"
, tableField "amounts_verified"
)
2019-07-21 12:53:00 +00:00
)