Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Kotahi
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Omo Oaiya
Kotahi
Commits
a15bc025
Commit
a15bc025
authored
4 years ago
by
Jure
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/clearAndSeed.js
+18
-4
18 additions, 4 deletions
scripts/clearAndSeed.js
with
18 additions
and
4 deletions
scripts/clearAndSeed.js
+
18
−
4
View file @
a15bc025
...
@@ -30,17 +30,31 @@ const clearDb = async () => {
...
@@ -30,17 +30,31 @@ const clearDb = async () => {
}
}
const
seed
=
async
dumpSql
=>
{
const
seed
=
async
dumpSql
=>
{
let
ready
if
(
dumpSql
)
{
if
(
dumpSql
)
{
await
clearDb
()
await
clearDb
()
await
db
.
raw
(
dumpSql
)
await
db
.
raw
(
dumpSql
)
logger
.
info
(
'
Cleared the database and restored from dump
'
)
logger
.
info
(
'
Cleared the database and restored from dump
'
)
// TODO: This wait is necessary for the database to "settle".
}
else
{
await
wait
(
2000
)
await
createTables
(
true
)
return
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
return
true
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment