Verified Commit 74055dc8 authored by Chocobozzz's avatar Chocobozzz
Browse files

Fix tests

parent 8b6f0fd5
......@@ -70,7 +70,9 @@ if (CONFIG.CSP.ENABLED) {
// ----------- Database -----------
// Initialize database and models
import { initDatabaseModels } from './server/initializers/database'
import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database'
checkDatabaseConnectionOrDie()
import { migrate } from './server/initializers/migrator'
migrate()
.then(() => initDatabaseModels(false))
......
......@@ -77,13 +77,15 @@ const sequelizeTypescript = new SequelizeTypescript({
}
})
sequelizeTypescript.authenticate()
.then(() => logger.debug('Connection to PostgreSQL has been established successfully.'))
.catch(err => {
logger.error('Unable to connect to PostgreSQL database.', { err })
process.exit(-1)
})
function checkDatabaseConnectionOrDie () {
sequelizeTypescript.authenticate()
.then(() => logger.debug('Connection to PostgreSQL has been established successfully.'))
.catch(err => {
logger.error('Unable to connect to PostgreSQL database.', { err })
process.exit(-1)
})
}
async function initDatabaseModels (silent: boolean) {
sequelizeTypescript.addModels([
......@@ -140,6 +142,7 @@ async function initDatabaseModels (silent: boolean) {
export {
initDatabaseModels,
checkDatabaseConnectionOrDie,
sequelizeTypescript
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment