commit 377c41dfe9f48b2b004ea7b9f133b643620031cf
parent 5313f79519dd4d80122677dae6f448567fbdcaad
Author: MS <ms@taler.net>
Date: Thu, 10 Dec 2020 16:28:06 +0100
Command line switch to drop DB tables.
Diffstat:
4 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -383,11 +383,30 @@ class NexusScheduledTaskEntity(id: EntityID<Int>) : IntEntity(id) {
var prevScheduledExecutionSec by NexusScheduledTasksTable.prevScheduledExecutionSec
}
+fun dbDropTables() {
+ transaction {
+ SchemaUtils.drop(
+ NexusUsersTable,
+ PaymentInitiationsTable,
+ NexusEbicsSubscribersTable,
+ NexusBankAccountsTable,
+ NexusBankTransactionsTable,
+ TalerIncomingPayments,
+ TalerRequestedPayments,
+ NexusBankConnectionsTable,
+ NexusBankMessagesTable,
+ FacadesTable,
+ TalerFacadeStateTable,
+ NexusScheduledTasksTable,
+ OfferedBankAccountsTable
+ )
+ }
+}
+
fun dbCreateTables(dbConnectionString: String) {
Database.connect("$dbConnectionString")
TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
transaction {
- addLogger(StdOutSqlLogger)
SchemaUtils.create(
NexusUsersTable,
PaymentInitiationsTable,
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -71,8 +71,14 @@ class ParseCamt : CliktCommand("Parse a camt file") {
}
}
+class DropTables : CliktCommand("Drop all the tables from the database") {
+ override fun run() {
+ dbDropTables()
+ }
+}
+
class Superuser : CliktCommand("Add superuser or change pw") {
- private val dbName by option().default("libeufindb")
+ private val dbName by option().default("jdbc:sqlite://libeufindb")
private val username by argument()
private val password by option().prompt(requireConfirmation = true, hideInput = true)
override fun run() {
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -301,6 +301,23 @@ object BankAccountReportsTable : IntIdTable() {
val bankAccount = reference("bankAccount", BankAccountsTable)
}
+fun dbDropTables() {
+ transaction {
+ SchemaUtils.drop(
+ EbicsSubscribersTable,
+ EbicsHostsTable,
+ EbicsDownloadTransactionsTable,
+ EbicsUploadTransactionsTable,
+ EbicsUploadTransactionChunksTable,
+ EbicsOrderSignaturesTable,
+ BankAccountTransactionsTable,
+ BankAccountsTable,
+ BankAccountReportsTable,
+ BankAccountStatementsTable
+ )
+ }
+}
+
fun dbCreateTables(dbConnectionString: String) {
Database.connect("${dbConnectionString}")
TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -92,6 +92,12 @@ class SandboxCommand : CliktCommand() {
override fun run() = Unit
}
+class DropTables : CliktCommand("Drop all the tables from the database") {
+ override fun run() {
+ dbDropTables()
+ }
+}
+
class Serve : CliktCommand("Run sandbox HTTP server") {
private val dbName by option().default("libeufindb")
private val logLevel by option()