summaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech/libeufin
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-07-25 13:13:42 +0200
committerMS <ms@taler.net>2023-07-25 13:13:42 +0200
commit54717e5c9630a5ed8bec955f06ba4e2359e20dfc (patch)
tree8ba64d0d1eb0aed223585581ce30cf8cac22018d /sandbox/src/main/kotlin/tech/libeufin
parent3b0a60b782a8273a3782b516ad30b560e80667f6 (diff)
downloadlibeufin-54717e5c9630a5ed8bec955f06ba4e2359e20dfc.tar.gz
libeufin-54717e5c9630a5ed8bec955f06ba4e2359e20dfc.tar.bz2
libeufin-54717e5c9630a5ed8bec955f06ba4e2359e20dfc.zip
Addressing #7890.
This allows users to specify (only) PostgreSQL connection strings in the environment.
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt16
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt8
2 files changed, 11 insertions, 13 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 934dbc4f..523b1bc3 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -31,12 +31,8 @@ import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.dao.id.LongIdTable
import org.jetbrains.exposed.sql.*
-import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
-import org.jetbrains.exposed.sql.transactions.transactionManager
-import tech.libeufin.sandbox.CashoutSubmissionsTable.nullable
import tech.libeufin.util.*
-import java.sql.Connection
import kotlin.reflect.*
import kotlin.reflect.full.*
@@ -666,14 +662,14 @@ class CashoutSubmissionEntity(id: EntityID<Long>) : LongEntity(id) {
var submissionTime by CashoutSubmissionsTable.submissionTime
}
-fun dbDropTables(dbConnectionString: String) {
- connectWithSchema(dbConnectionString)
+fun dbDropTables(connStringFromEnv: String) {
+ connectWithSchema(getJdbcConnectionFromPg(connStringFromEnv))
if (isPostgres()) {
val ret = execCommand(
listOf(
"libeufin-load-sql",
"-d",
- getDatabaseName(),
+ connStringFromEnv,
"-s",
"sandbox",
"-r" // the drop option
@@ -713,13 +709,13 @@ fun dbDropTables(dbConnectionString: String) {
}
-fun dbCreateTables(dbConnectionString: String) {
- connectWithSchema(dbConnectionString)
+fun dbCreateTables(connStringFromEnv: String) {
+ connectWithSchema(getJdbcConnectionFromPg(connStringFromEnv))
if (isPostgres()) {
execCommand(listOf(
"libeufin-load-sql",
"-d",
- getDatabaseName(),
+ connStringFromEnv,
"-s",
"sandbox"
))
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 42a2a515..bfd521cc 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -231,7 +231,7 @@ class Camt053Tick : CliktCommand(
) {
override fun run() {
val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)
- dbCreateTables(dbConnString)
+ execThrowableOrTerminate { dbCreateTables(dbConnString) }
val newStatements = mutableMapOf<String, MutableList<XLibeufinBankTransaction>>()
/**
* For each bank account, extract the latest statement and
@@ -293,13 +293,15 @@ class MakeTransaction : CliktCommand("Wire-transfer money between Sandbox bank a
private val subjectArg by argument("SUBJECT", "Payment's subject")
override fun run() {
- val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)
/**
* Merely connecting here (and NOT creating any table) because this
* command should only be run after actual bank accounts exist in the
* system, meaning therefore that the database got already set up.
*/
- connectWithSchema(dbConnString)
+ execThrowableOrTerminate {
+ val pgConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)
+ connectWithSchema(getJdbcConnectionFromPg(pgConnString))
+ }
// Refuse to operate without a default demobank.
val demobank = getDemobank("default")
if (demobank == null) {