feature #10: log Query
This commit is contained in:
@@ -154,10 +154,10 @@ data class Migrations private constructor(
|
||||
private fun initDB() {
|
||||
if (!initialized) {
|
||||
File(this::class.java.getResource("/sql/migration/createHistoryShema.sql").toURI()).let {
|
||||
connection.connect().sendQuery(it.readText()).join()
|
||||
connection.sendQuery(it.readText())
|
||||
}
|
||||
File(this::class.java.getResource("/sql/migration/createFunctionShema.sql").toURI()).let {
|
||||
connection.connect().sendQuery(it.readText()).join()
|
||||
connection.sendQuery(it.readText())
|
||||
}
|
||||
initialized = true
|
||||
}
|
||||
@@ -165,7 +165,7 @@ data class Migrations private constructor(
|
||||
|
||||
private fun lock() {
|
||||
File(this::class.java.getResource("/sql/migration/lockMigrationTables.sql").toURI()).let {
|
||||
connection.connect().sendQuery(it.readText()).join()
|
||||
connection.sendQuery(it.readText())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ data class Migrations private constructor(
|
||||
|
||||
fun run(): Map<Pair<String, Direction>, Status> {
|
||||
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
||||
connection.connect().apply {
|
||||
sendQuery("BEGIN").join()
|
||||
connection.apply {
|
||||
sendQuery("BEGIN")
|
||||
lock()
|
||||
up().map {
|
||||
list[Pair(it.key, Direction.UP)] = it.value
|
||||
@@ -230,7 +230,7 @@ data class Migrations private constructor(
|
||||
down(true).map {
|
||||
list[Pair(it.key, Direction.DOWN)] = it.value
|
||||
}
|
||||
sendQuery("COMMIT").join()
|
||||
sendQuery("COMMIT")
|
||||
}
|
||||
|
||||
return list.toMap()
|
||||
@@ -242,15 +242,15 @@ data class Migrations private constructor(
|
||||
|
||||
private fun runTest(): Map<Pair<String, Direction>, Status> {
|
||||
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
||||
connection.connect().apply {
|
||||
sendQuery("BEGIN").join()
|
||||
connection.apply {
|
||||
sendQuery("BEGIN")
|
||||
up().map {
|
||||
list[Pair(it.key, Direction.UP)] = it.value
|
||||
}
|
||||
down(true).map {
|
||||
list[Pair(it.key, Direction.DOWN)] = it.value
|
||||
}
|
||||
sendQuery("ROLLBACK").join()
|
||||
sendQuery("ROLLBACK")
|
||||
}
|
||||
|
||||
return list.toMap()
|
||||
|
||||
@@ -16,7 +16,7 @@ data class Query(
|
||||
override var doExecute: Action? = null
|
||||
|
||||
override fun up(): Migration.Status {
|
||||
connection.exec(up).join()
|
||||
connection.exec(up)
|
||||
|
||||
File(this::class.java.getResource("/sql/migration/insertHistory.sql").toURI()).let {
|
||||
connection.selectOne<MigrationEntity>(it.readText(), listOf(name, up, down))?.let { query ->
|
||||
@@ -29,7 +29,7 @@ data class Query(
|
||||
}
|
||||
|
||||
override fun down(): Migration.Status {
|
||||
connection.exec(down).join()
|
||||
connection.exec(down)
|
||||
|
||||
File(this::class.java.getResource("/sql/migration/deleteHistory.sql").toURI()).let {
|
||||
connection.exec(it.readText(), listOf(name))
|
||||
|
||||
Reference in New Issue
Block a user