Switch to decimal from money.

This commit is contained in:
Nick 2023-03-10 14:40:27 +00:00
parent cac01c80e2
commit 9e378b675f
2 changed files with 4 additions and 2 deletions

View File

@ -7,11 +7,13 @@ import Data.Money.Internal
import Data.Scientific
import Rel8
import Debug.Trace
instance DBType (Money curr) where
typeInformation =
let sci = typeInformation @Scientific
in TypeInformation { encode = encode sci . realToFrac . getAmount
, decode = fmap (Money . realToFrac) (decode sci)
, typeName = "money"
, typeName = "decimal"
}

View File

@ -48,7 +48,7 @@ createConnection = throwLeft =<< Hasql.acquire dbsets
createTable :: Connection -> IO ()
createTable conn = throwLeft =<< Hasql.run sql conn
where sql = Hasql.sql "CREATE TABLE bucks (amount money not null);"
where sql = Hasql.sql "CREATE TABLE bucks (amount decimal not null);"
dropTable :: Connection -> IO ()
dropTable conn = throwLeft =<< Hasql.run sql conn