Fix tests
This commit is contained in:
parent
8b6f0fd53d
commit
74055dc882
|
@ -70,7 +70,9 @@ if (CONFIG.CSP.ENABLED) {
|
||||||
// ----------- Database -----------
|
// ----------- Database -----------
|
||||||
|
|
||||||
// Initialize database and models
|
// Initialize database and models
|
||||||
import { initDatabaseModels } from './server/initializers/database'
|
import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database'
|
||||||
|
checkDatabaseConnectionOrDie()
|
||||||
|
|
||||||
import { migrate } from './server/initializers/migrator'
|
import { migrate } from './server/initializers/migrator'
|
||||||
migrate()
|
migrate()
|
||||||
.then(() => initDatabaseModels(false))
|
.then(() => initDatabaseModels(false))
|
||||||
|
|
|
@ -77,13 +77,15 @@ const sequelizeTypescript = new SequelizeTypescript({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
sequelizeTypescript.authenticate()
|
function checkDatabaseConnectionOrDie () {
|
||||||
.then(() => logger.debug('Connection to PostgreSQL has been established successfully.'))
|
sequelizeTypescript.authenticate()
|
||||||
.catch(err => {
|
.then(() => logger.debug('Connection to PostgreSQL has been established successfully.'))
|
||||||
|
.catch(err => {
|
||||||
|
|
||||||
logger.error('Unable to connect to PostgreSQL database.', { err })
|
logger.error('Unable to connect to PostgreSQL database.', { err })
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function initDatabaseModels (silent: boolean) {
|
async function initDatabaseModels (silent: boolean) {
|
||||||
sequelizeTypescript.addModels([
|
sequelizeTypescript.addModels([
|
||||||
|
@ -140,6 +142,7 @@ async function initDatabaseModels (silent: boolean) {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
initDatabaseModels,
|
initDatabaseModels,
|
||||||
|
checkDatabaseConnectionOrDie,
|
||||||
sequelizeTypescript
|
sequelizeTypescript
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue