Clean
This commit is contained in:
parent
2a583ed399
commit
1c8c7ba8d7
@ -31,7 +31,7 @@ fun Application.module() {
|
|||||||
import(configurationModule)
|
import(configurationModule)
|
||||||
import(serviceModule)
|
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>()) }
|
bind<Database>() with singleton { Database.Companion.connect(this.instance<DataSource>()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +39,8 @@ fun Application.module() {
|
|||||||
|
|
||||||
log.debug(kodein.container.tree.bindings.description())
|
log.debug(kodein.container.tree.bindings.description())
|
||||||
|
|
||||||
// TODO, clean this (migration)
|
val migration by kodein.instance<Migration>()
|
||||||
val feature by kodein.instance<Feature>()
|
migration.migrate()
|
||||||
feature.execute()
|
|
||||||
|
|
||||||
val controllers by kodein.instance<Set<KodeinController>>()
|
val controllers by kodein.instance<Set<KodeinController>>()
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
package be.vandewalleh.migrations
|
package be.vandewalleh.migrations
|
||||||
|
|
||||||
import be.vandewalleh.features.Feature
|
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.kodein.di.Kodein
|
import org.kodein.di.Kodein
|
||||||
|
import org.kodein.di.KodeinAware
|
||||||
import org.kodein.di.generic.instance
|
import org.kodein.di.generic.instance
|
||||||
import javax.sql.DataSource
|
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 dataSource by instance<DataSource>()
|
||||||
val flyway = Flyway.configure()
|
val flyway = Flyway.configure()
|
||||||
.dataSource(dataSource)
|
.dataSource(dataSource)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user