Correct types

This commit is contained in:
Rene Vergara 2024-08-12 10:42:30 -05:00
parent e24581eb5d
commit 8be9215f04
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

205
src/DB.hs
View file

@ -22,6 +22,7 @@ import Control.Exception (throwIO)
import Control.Monad (forM_, when)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Data.Aeson
import Data.Bifunctor (bimap)
import qualified Data.ByteString as BS
import Data.HexString
@ -29,140 +30,154 @@ import Data.List (group, sort)
import Data.Maybe (catMaybes, fromJust, isJust)
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Time (UTCTime(..))
import Data.UUID (UUID)
import Data.Word
import Database.Esqueleto.Experimental
import qualified Database.Persist.MySQL as PM
import Database.Persist.TH
newtype UuidDB = UuidDB
{ getUUID :: UUID
} deriving newtype (Eq, Show, Read, ToJSON, FromJSON)
derivePersistFieldJSON "UuidDB"
newtype HexStringDB = HexStringDB
{ getHex :: HexString
} deriving newtype (Eq, Show, Read)
derivePersistField "HexStringDB"
share
[mkPersist sqlSettings, mkMigrate "migrateAll"]
[persistLowerCase|
ZgoBlock
block_confs Int default=0
block_network String default=""
block_height Int default=0
block_time Int default=0
ZgoBlock json
confs Int default=0
network String default=""
height Int default=0
time Int default=0
deriving Show Eq
ZgoBlockTx
ZgoBlockTx
blocktx_block_id Int
blocktx_id Int
blocktx_txid String
deriving Show Eq
ZgoCountry
country_code String
country_name String
UniqueCountryCode country_code
ZgoCountry json
code T.Text
name T.Text
UniqueCountryCode code
deriving Show Eq
ZgoItem
item_owner_id Int
item_name String
item_description T.Text default=""
item_cost Float default=0.0
ZgoItem json
owner_id Int
name T.Text
description T.Text default=""
cost Double default=0.0
deriving Show Eq
ZgoLanguages
encode_id String
view_name String default-""
view_element String default=""
view_element_text T.Text default=""
encode_id T.Text
name T.Text default-""
element T.Text default=""
element_text T.Text default=""
deriving Show Eq
ZgoOrders
order_zaddress T.Text
order_session T.Text
order_timestamp Int
order_closed Word8
order_currency String
order_price Float default=0.0
order_total Float default=0.0
order_totalzec Float default=0.0
order_paid Word8 default=0
order_token String default=""
order_extinv String default=""
order_shortcode String default=''
order_taxamount Float default=0.0
order_tipamount Float default=0.0
order_vatamount Float default=0.0
ZgoOrder json
owner ZgoOwnerId
session ZgoUserId
timestamp Int
closed Word8
currency T.Text
price Double
total Double
totalzec Double
paid Bool
token T.Text default=""
externalInvoice T.Text default=""
shortcode T.Text
taxamount Double
tipamount Double
vatamount Double
deriving Show Eq
ZgoOrderLines
orderline_orderid Int default=0
orderline_qty Int default=0
orderline_name T.Text default=""
orderline_cost Float default=0.0
orderId ZgoOrderId
qty Int default=0
name T.Text default=""
cost Double default=0.0
deriving Show Eq
ZgoOwner
owner_co_name String default=""
owner_firstname String
owner_lastname String
owner_email String
owner_street String
owner_city String
owner_state String
owner_zipcode String
owner_phone String
owner_country String
owner_website String
owner_currency String
owner_zcaddress String
owner_usezats Word8
owner_crmtoken T.Text
owner_usetax Word8
owner_taxvalue Float
owner_usevat Word8
owner_vat Float
owner_payconf Word8
owner_viewkey T.Text
owner_invoices Word8
owner_tips Word8
owner_paid Word8
owner_expiration Int
co_name T.Text
firstname T.Text
lastname T.Text
email T.Text
street T.Text
city T.Text
state T.Text
zipcode T.Text
phone T.Text
country T.Text
website T.Text
currency T.Text
zcaddress T.Text
usezats Bool
crmtoken T.Text
usetax Bool
taxvalue Double
usevat Bool
vat Double
payconf Bool
viewkey T.Text
invoices Bool
tips Bool
paid Bool
expiration UTCTime
deriving Show Eq
ZgoPayment
payment_delta Int
payment_done Word8
payment_zaddress T.Text
payment_session String default=""
payment_blocktime Int default=0
payment_amount Float default=0.0
payment_txid String default =""
payment_memo T.Text default=""
delta Int
done Bool
zaddress T.Text
session UuidDB
blocktime Int default=0
amount Double default=0.0
txid HexStringDB
memo T.Text
deriving Show Eq
ZgoPrice
price_delta Int default=0
price_done Word8 default=0
price_done Bool default=0
price_zaddress T.Text default=""
price_session String default=""
price_blocktime Int default=0
price_amount Float default=0.0
price_amount Double default=0.0
price_txid String default=""
price_memo T.Text default=""
deriving Show Eq
ZgoProsession
pro_zaddress T.Text default=""
pro_expiration Int default=0
pro_closed Word8 default=0
zaddress T.Text default=""
expiration UTCTime
closed Bool
deriving Show Eq
ZgoTransaction
tx_zaddress T.Text default=""
tx_expiration Int default=0
tx_closed Word8 default=0
zaddress T.Text default=""
expiration Int default=0
closed Word8 default=0
deriving Show Eq
ZgoUser
user_zaddress T.Text
user_session String
user_blocktime Int
user_pin String
user_validated Word8 default=0
ZgoUser json
owner ZgoOwnerId
session UuidDB
blocktime Int
pin T.Text
validated Bool
deriving Show Eq
ZgoXero
xero_client_id String default=""
xero_client_secret String default=""
client_id T.Text default=""
client_secret T.Text default=""
deriving Show Eq
ZgoXeroToken
xerotoken_zaddress T.Text
xerotoken_access_token T.Text
xerotoken_expires Int
xerotoken_refreshtoken String
xerotoken_accexpires Int
xerotoken_accCode String
xerotoken_refexpires Int
zaddress T.Text
access_token T.Text
expires Int
refreshtoken T.Text
accexpires Int
accCode T.Text
refexpires Int
deriving Show Eq
|]