This commit is contained in:
Hubert Van De Walle 2020-04-20 16:28:55 +02:00
parent 2a583ed399
commit 1c8c7ba8d7
2 changed files with 6 additions and 7 deletions

View File

@ -31,7 +31,7 @@ fun Application.module() {
import(configurationModule)
import(serviceModule)
bind<Feature>() with singleton { Migration(this.kodein) }
bind<Migration>() with singleton { Migration(this.kodein) }
bind<Database>() with singleton { Database.Companion.connect(this.instance<DataSource>()) }
}
@ -39,9 +39,8 @@ fun Application.module() {
log.debug(kodein.container.tree.bindings.description())
// TODO, clean this (migration)
val feature by kodein.instance<Feature>()
feature.execute()
val migration by kodein.instance<Migration>()
migration.migrate()
val controllers by kodein.instance<Set<KodeinController>>()

View File

@ -1,14 +1,14 @@
package be.vandewalleh.migrations
import be.vandewalleh.features.Feature
import org.flywaydb.core.Flyway
import org.kodein.di.Kodein
import org.kodein.di.KodeinAware
import org.kodein.di.generic.instance
import javax.sql.DataSource
class Migration(override val kodein: Kodein) : Feature(kodein) {
class Migration(override val kodein: Kodein) : KodeinAware {
override fun execute() {
fun migrate() {
val dataSource by instance<DataSource>()
val flyway = Flyway.configure()
.dataSource(dataSource)