start amounts implementation
This commit is contained in:
parent
57aacb1e21
commit
b077036caa
41
src/Model/Amount.hs
Normal file
41
src/Model/Amount.hs
Normal file
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
initAmount = foldl (<>) "" $
|
||||
[ "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"
|
||||
)
|
Loading…
Reference in a new issue