diff --git a/src/Model/Auth.hs b/src/Model/Auth.hs index 461cd75..81b042c 100644 --- a/src/Model/Auth.hs +++ b/src/Model/Auth.hs @@ -49,7 +49,13 @@ import Model.User initToken :: PGS.Query -initToken = "create table if not exists \"token\" (token_string bytea not null primary key, token_user integer references \"user\"(user_id) not null, token_expiry timestamptz not null)" +initToken = mconcat + [ "create table if not exists \"token\" (" + , "token_string bytea not null primary key," + , "token_user integer references \"user\"(user_id) not null," + , "token_expiry timestamptz not null" + , ")" + ] tokenTable :: Table ( Field SqlBytea diff --git a/src/Model/Product.hs b/src/Model/Product.hs index 604c9e5..812a177 100644 --- a/src/Model/Product.hs +++ b/src/Model/Product.hs @@ -4,7 +4,7 @@ module Model.Product where import Servant.Server -import Data.Text as T hiding (head) +import Data.Text as T hiding (head, foldl) import Data.Time.Calendar (Day) import Data.Profunctor.Product (p13) @@ -31,7 +31,23 @@ import Opaleye.Constant as C import Types initProduct :: PGS.Query -initProduct = "create Table if not exists \"product\" (product_id serial primary key, product_ident varchar(128) not null, product_price integer not null, product_amount integer not null, product_vanish integer not null, product_ml integer not null, product_avatar integer, product_supplier integer, product_max_amount integer not null, product_total_bought integer not null, product_amount_per_crate integer not null, product_price_per_crate integer, product_art_nr varchar(128))" +initProduct = mconcat + [ "create table if not exists \"product\" (" + , "product_id serial primary key," + , "product_ident varchar(128) not null," + , "product_price integer not null," + , "product_amount integer not null," + , "product_vanish integer not null," + , "product_ml integer not null," + , "product_avatar integer," + , "product_supplier integer," + , "product_max_amount integer not null," + , "product_total_bought integer not null," + , "product_amount_per_crate integer not null," + , "product_price_per_crate integer," + , "product_art_nr varchar(128)" + , ")" + ] productTable :: Table ( Maybe (Field SqlInt4) diff --git a/src/Model/User.hs b/src/Model/User.hs index 2848994..f0e6627 100644 --- a/src/Model/User.hs +++ b/src/Model/User.hs @@ -3,7 +3,7 @@ {-# LANGUAGE DuplicateRecordFields #-} module Model.User where -import Data.Text as T hiding (head) +import Data.Text as T hiding (head, foldl) import Data.Time.Calendar import Data.Time.Clock @@ -11,7 +11,7 @@ import Data.Profunctor.Product (p9) import Data.Maybe (fromJust, isJust, fromMaybe) -import Data.ByteString hiding (head) +import Data.ByteString hiding (head, foldl) import Data.Int (Int64) @@ -34,7 +34,19 @@ import Types.Auth import Types.Reader initUser :: PGS.Query -initUser = "create table if not exists \"user\" (user_id serial primary key, user_ident varchar(128) not null, user_balance integer not null, user_timestamp date not null, user_email varchar(128), user_avatar integer, user_salt bytea not null, user_hash bytea, user_algo integer)" +initUser = mconcat + [ "create table if not exists \"user\" (" + , "user_id serial primary key," + , "user_ident varchar(128) not null," + , "user_balance integer not null," + , "user_timestamp date not null," + , "user_email varchar(128)," + , "user_avatar integer," + , "user_salt bytea not null," + , "user_hash bytea," + , "user_algo integer" + , ")" + ] userTable :: Table ( Maybe (Field SqlInt4)