Skip to content
Snippets Groups Projects
Commit a15bc025 authored by Jure's avatar Jure
Browse files

fix: use a different method for waiting on db readiness

parent 82af688b
No related branches found
No related tags found
No related merge requests found
......@@ -30,17 +30,31 @@ const clearDb = async () => {
}
const seed = async dumpSql => {
let ready
if (dumpSql) {
await clearDb()
await db.raw(dumpSql)
logger.info('Cleared the database and restored from dump')
// TODO: This wait is necessary for the database to "settle".
await wait(2000)
return true
} else {
await createTables(true)
}
await createTables(true)
// TODO: This wait is necessary for the database to "settle".
while (!ready) {
// eslint-disable-next-line
const { rows } = await db.raw(`SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = 'users'
);`)
if (rows && rows[0] && rows[0].exists) {
ready = true
}
// eslint-disable-next-line
await wait(1000)
}
return true
}
......
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