Fix enum class Status()

This commit is contained in:
2022-10-15 00:38:51 +02:00
parent 6522818cde
commit 0491a444aa
2 changed files with 31 additions and 23 deletions

View File

@@ -37,6 +37,7 @@ data class Function(
) )
override fun up(): Status { override fun up(): Status {
return try {
try { try {
connection.sendQuery(up.script) connection.sendQuery(up.script)
} catch (e: CompletionException) { } catch (e: CompletionException) {
@@ -55,10 +56,14 @@ data class Function(
doExecute = Action.OK doExecute = Action.OK
} }
return Status.OK Status.OK
} catch (e: Throwable) {
Status.UP_FAIL
}
} }
override fun down(): Status { override fun down(): Status {
return try {
connection.sendQuery(down.script) connection.sendQuery(down.script)
this::class.java.classLoader this::class.java.classLoader
@@ -66,7 +71,10 @@ data class Function(
.readText() .readText()
.let { connection.sendQuery(it, listOf(down.name)) } .let { connection.sendQuery(it, listOf(down.name)) }
return Status.OK Status.OK
} catch (e: Throwable) {
Status.DOWN_FAIL
}
} }
override fun test(): Status { override fun test(): Status {

View File

@@ -29,7 +29,7 @@ interface Migration {
fun down(): Status fun down(): Status
fun test(): Status fun test(): Status
enum class Status(i: Int) { OK(2), UP_FAIL(0), DOWN_FAIL(1) } enum class Status(val i: Int) { OK(2), UP_FAIL(0), DOWN_FAIL(1) }
enum class Action { OK, UP, DOWN } enum class Action { OK, UP, DOWN }
} }