Compare commits
3 Commits
866a9b19d8
...
c4a135817a
| Author | SHA1 | Date | |
|---|---|---|---|
|
c4a135817a
|
|||
|
3bf33999e4
|
|||
|
69dc768052
|
@@ -1,5 +1,5 @@
|
|||||||
group = "com.infendro"
|
group = "com.infendro"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.infendro.migration
|
package com.infendro.migration
|
||||||
|
|
||||||
|
import com.infendro.migration.exception.DuplicateMigrationException
|
||||||
import com.infendro.migration.model.MigrationRepository
|
import com.infendro.migration.model.MigrationRepository
|
||||||
import com.infendro.migration.model.MigrationTable
|
import com.infendro.migration.model.MigrationTable
|
||||||
import org.jetbrains.exposed.sql.SchemaUtils
|
import org.jetbrains.exposed.sql.SchemaUtils
|
||||||
@@ -36,6 +37,7 @@ fun migrate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED")
|
||||||
fun migrate(
|
fun migrate(
|
||||||
configure: Config.() -> Unit
|
configure: Config.() -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -47,10 +49,15 @@ fun migrate(
|
|||||||
class Config {
|
class Config {
|
||||||
internal val migrations: MutableList<Migration> = mutableListOf()
|
internal val migrations: MutableList<Migration> = mutableListOf()
|
||||||
|
|
||||||
|
@Suppress("UNUSED")
|
||||||
fun migration(
|
fun migration(
|
||||||
name: String,
|
name: String,
|
||||||
migrate: Transaction.() -> Unit,
|
migrate: Transaction.() -> Unit,
|
||||||
) {
|
) {
|
||||||
|
if (migrations.any { it.name == name }) {
|
||||||
|
throw DuplicateMigrationException(name)
|
||||||
|
}
|
||||||
|
|
||||||
migrations += Migration(name, migrate)
|
migrations += Migration(name, migrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.infendro.migration.exception
|
||||||
|
|
||||||
|
class DuplicateMigrationException(
|
||||||
|
val name: String,
|
||||||
|
) : Exception()
|
||||||
Reference in New Issue
Block a user