feature: add forceAllDown to migration
This commit is contained in:
@@ -227,7 +227,7 @@ data class Migrations private constructor(
|
|||||||
up().map {
|
up().map {
|
||||||
list[Pair(it.key, Direction.UP)] = it.value
|
list[Pair(it.key, Direction.UP)] = it.value
|
||||||
}
|
}
|
||||||
down(true).map {
|
down().map {
|
||||||
list[Pair(it.key, Direction.DOWN)] = it.value
|
list[Pair(it.key, Direction.DOWN)] = it.value
|
||||||
}
|
}
|
||||||
sendQuery("COMMIT")
|
sendQuery("COMMIT")
|
||||||
@@ -240,6 +240,20 @@ data class Migrations private constructor(
|
|||||||
return this.copy().runTest()
|
return this.copy().runTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun forceAllDown(): Map<Pair<String, Direction>, Status> {
|
||||||
|
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
||||||
|
connection.apply {
|
||||||
|
sendQuery("BEGIN")
|
||||||
|
lock()
|
||||||
|
down(true).map {
|
||||||
|
list[Pair(it.key, Direction.DOWN)] = it.value
|
||||||
|
}
|
||||||
|
sendQuery("COMMIT")
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.toMap()
|
||||||
|
}
|
||||||
|
|
||||||
private fun runTest(): Map<Pair<String, Direction>, Status> {
|
private fun runTest(): Map<Pair<String, Direction>, Status> {
|
||||||
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
||||||
connection.apply {
|
connection.apply {
|
||||||
|
|||||||
@@ -69,7 +69,17 @@ class MigrationTest(): TestAbstract() {
|
|||||||
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
|
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
|
||||||
Migrations(resources, getConnextion()).apply {
|
Migrations(resources, getConnextion()).apply {
|
||||||
run().apply {
|
run().apply {
|
||||||
size `should be equal to` 2
|
size `should be equal to` 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `run migrations force down`() {
|
||||||
|
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
|
||||||
|
Migrations(resources, getConnextion()).apply {
|
||||||
|
forceAllDown().apply {
|
||||||
|
size `should be equal to` 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user