Scaffolding updates, including #982
This commit is contained in:
parent
3683961ac1
commit
d82a828d89
@ -101,6 +101,9 @@ makeFoundation appSettings = do
|
||||
-- temporary foundation without a real connection pool, get a log function
|
||||
-- from there, and then create the real foundation.
|
||||
let mkFoundation appConnPool = App {..}
|
||||
-- The App {..} syntax is an example of record wild cards. For more
|
||||
-- information, see:
|
||||
-- https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html
|
||||
tempFoundation = mkFoundation $ error "connPool forced in tempFoundation"
|
||||
logFunc = messageLoggerSource tempFoundation appLogger
|
||||
|
||||
@ -9159,19 +9162,17 @@ withApp = before $ do
|
||||
-- 'withApp' calls it before each test, creating a clean environment for each
|
||||
-- spec to run in.
|
||||
wipeDB :: App -> IO ()
|
||||
wipeDB app = do
|
||||
runDBWithApp app $ do
|
||||
tables <- getTables
|
||||
sqlBackend <- ask
|
||||
let queries = map (\t -> "TRUNCATE TABLE " ++ (connEscapeName sqlBackend $ DBName t)) tables
|
||||
wipeDB app = runDBWithApp app $ do
|
||||
tables <- getTables
|
||||
sqlBackend <- ask
|
||||
let queries = map (\t -> "TRUNCATE TABLE " ++ connEscapeName sqlBackend (DBName t)) tables
|
||||
|
||||
-- In MySQL, a table cannot be truncated if another table references it via foreign key.
|
||||
-- Since we're wiping both the parent and child tables, though, it's safe
|
||||
-- to temporarily disable this check.
|
||||
rawExecute "SET foreign_key_checks = 0;" []
|
||||
forM_ queries (\q -> rawExecute q [])
|
||||
rawExecute "SET foreign_key_checks = 1;" []
|
||||
return ()
|
||||
-- In MySQL, a table cannot be truncated if another table references it via foreign key.
|
||||
-- Since we're wiping both the parent and child tables, though, it's safe
|
||||
-- to temporarily disable this check.
|
||||
rawExecute "SET foreign_key_checks = 0;" []
|
||||
forM_ queries (\q -> rawExecute q [])
|
||||
rawExecute "SET foreign_key_checks = 1;" []
|
||||
|
||||
getTables :: MonadIO m => ReaderT SqlBackend m [Text]
|
||||
getTables = do
|
||||
|
||||
@ -107,6 +107,9 @@ makeFoundation appSettings = do
|
||||
-- temporary foundation without a real connection pool, get a log function
|
||||
-- from there, and then create the real foundation.
|
||||
let mkFoundation appConnPool = App {..}
|
||||
-- The App {..} syntax is an example of record wild cards. For more
|
||||
-- information, see:
|
||||
-- https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html
|
||||
tempFoundation = mkFoundation $ error "connPool forced in tempFoundation"
|
||||
logFunc = messageLoggerSource tempFoundation appLogger
|
||||
|
||||
@ -1062,11 +1065,11 @@ ip-from-header: "_env:IP_FROM_HEADER:false"
|
||||
# skip-combining: false
|
||||
|
||||
database:
|
||||
user: "_env:PGUSER:PROJECTNAME"
|
||||
user: "_env:PGUSER:PROJECTNAME_LOWER"
|
||||
password: "_env:PGPASS:PROJECTNAME"
|
||||
host: "_env:PGHOST:localhost"
|
||||
port: "_env:PGPORT:5432"
|
||||
database: "_env:PGDATABASE:PROJECTNAME"
|
||||
database: "_env:PGDATABASE:PROJECTNAME_LOWER"
|
||||
poolsize: "_env:PGPOOLSIZE:10"
|
||||
|
||||
copyright: Insert copyright statement here
|
||||
@ -1074,7 +1077,7 @@ copyright: Insert copyright statement here
|
||||
|
||||
{-# START_FILE config/test-settings.yml #-}
|
||||
database:
|
||||
database: PROJECTNAME_test
|
||||
database: PROJECTNAME_LOWER_test
|
||||
|
||||
{-# START_FILE fay-shared/SharedTypes.hs #-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
|
||||
@ -101,6 +101,9 @@ makeFoundation appSettings = do
|
||||
-- temporary foundation without a real connection pool, get a log function
|
||||
-- from there, and then create the real foundation.
|
||||
let mkFoundation appConnPool = App {..}
|
||||
-- The App {..} syntax is an example of record wild cards. For more
|
||||
-- information, see:
|
||||
-- https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html
|
||||
tempFoundation = mkFoundation $ error "connPool forced in tempFoundation"
|
||||
logFunc = messageLoggerSource tempFoundation appLogger
|
||||
|
||||
@ -1002,11 +1005,11 @@ ip-from-header: "_env:IP_FROM_HEADER:false"
|
||||
# skip-combining: false
|
||||
|
||||
database:
|
||||
user: "_env:PGUSER:PROJECTNAME"
|
||||
user: "_env:PGUSER:PROJECTNAME_LOWER"
|
||||
password: "_env:PGPASS:PROJECTNAME"
|
||||
host: "_env:PGHOST:localhost"
|
||||
port: "_env:PGPORT:5432"
|
||||
database: "_env:PGDATABASE:PROJECTNAME"
|
||||
database: "_env:PGDATABASE:PROJECTNAME_LOWER"
|
||||
poolsize: "_env:PGPOOLSIZE:10"
|
||||
|
||||
copyright: Insert copyright statement here
|
||||
@ -1014,7 +1017,7 @@ copyright: Insert copyright statement here
|
||||
|
||||
{-# START_FILE config/test-settings.yml #-}
|
||||
database:
|
||||
database: PROJECTNAME_test
|
||||
database: PROJECTNAME_LOWER_test
|
||||
|
||||
{-# START_FILE static/css/bootstrap.css #-}
|
||||
/*!
|
||||
|
||||
@ -894,8 +894,7 @@ copyright: Insert copyright statement here
|
||||
#analytics: UA-YOURCODE
|
||||
|
||||
{-# START_FILE config/test-settings.yml #-}
|
||||
database:
|
||||
database: PROJECTNAME_test
|
||||
{}
|
||||
|
||||
{-# START_FILE static/css/bootstrap.css #-}
|
||||
/*!
|
||||
|
||||
@ -101,6 +101,9 @@ makeFoundation appSettings = do
|
||||
-- temporary foundation without a real connection pool, get a log function
|
||||
-- from there, and then create the real foundation.
|
||||
let mkFoundation appConnPool = App {..}
|
||||
-- The App {..} syntax is an example of record wild cards. For more
|
||||
-- information, see:
|
||||
-- https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html
|
||||
tempFoundation = mkFoundation $ error "connPool forced in tempFoundation"
|
||||
logFunc = messageLoggerSource tempFoundation appLogger
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user