mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
Fix race condition related to sqlite3 database not being created before we access it (#4479)
This commit is contained in:
parent
1ae4d40dac
commit
84ce76e16c
1 changed files with 9 additions and 8 deletions
|
@ -16,6 +16,15 @@ trait DbManagement extends Logging {
|
|||
import scala.language.implicitConversions
|
||||
|
||||
protected lazy val flyway: Flyway = {
|
||||
//create the database if it doesn't exist yet in sqlite3
|
||||
appConfig.driver match {
|
||||
case SQLite =>
|
||||
SQLiteUtil.createDbFileIfDNE(appConfig.dbPath, appConfig.dbName)
|
||||
val jdbcUrl = appConfig.jdbcUrl.replace("\"", "")
|
||||
SQLiteUtil.setJournalMode(jdbcUrl, "WAL")
|
||||
case PostgreSQL =>
|
||||
()
|
||||
}
|
||||
val module = appConfig.moduleName
|
||||
|
||||
val driverName = appConfig.driver match {
|
||||
|
@ -157,14 +166,6 @@ trait DbManagement extends Logging {
|
|||
*/
|
||||
def migrate(): MigrateResult = {
|
||||
try {
|
||||
appConfig.driver match {
|
||||
case SQLite =>
|
||||
SQLiteUtil.createDbFileIfDNE(appConfig.dbPath, appConfig.dbName)
|
||||
val jdbcUrl = appConfig.jdbcUrl.replace("\"", "")
|
||||
SQLiteUtil.setJournalMode(jdbcUrl, "WAL")
|
||||
case PostgreSQL =>
|
||||
()
|
||||
}
|
||||
flyway.migrate()
|
||||
} catch {
|
||||
case err: FlywayException =>
|
||||
|
|
Loading…
Add table
Reference in a new issue