refactoring: definition.Function

This commit is contained in:
2019-07-01 16:58:19 +02:00
parent ebc1a67420
commit 74c9543b6d
6 changed files with 67 additions and 46 deletions

View File

@@ -4,12 +4,19 @@ import fr.postgresjson.connexion.Connection
import fr.postgresjson.definition.Function as DefinitionFunction
class Function(
private val up: DefinitionFunction,
private val down: DefinitionFunction,
val up: DefinitionFunction,
val down: DefinitionFunction,
private val connection: Connection
): Migration {
val name = up.name
enum class Status(i: Int) { OK(2), UP_FAIL(0), DOWN_FAIL(1) }
init {
if (up.name !== down.name) {
throw Exception("UP and DOWN migration must be the same")
}
}
override fun up(): Int {
connection.exec(up.script)
return 1