feature: add forceAllDown to migration
This commit is contained in:
@@ -227,7 +227,7 @@ data class Migrations private constructor(
|
||||
up().map {
|
||||
list[Pair(it.key, Direction.UP)] = it.value
|
||||
}
|
||||
down(true).map {
|
||||
down().map {
|
||||
list[Pair(it.key, Direction.DOWN)] = it.value
|
||||
}
|
||||
sendQuery("COMMIT")
|
||||
@@ -240,6 +240,20 @@ data class Migrations private constructor(
|
||||
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> {
|
||||
val list: MutableMap<Pair<String, Direction>, Status> = mutableMapOf()
|
||||
connection.apply {
|
||||
|
||||
@@ -69,7 +69,17 @@ class MigrationTest(): TestAbstract() {
|
||||
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
|
||||
Migrations(resources, getConnextion()).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