You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
894 B
Kotlin
29 lines
894 B
Kotlin
package moe.odango.index.cli
|
|
|
|
import com.github.ajalt.clikt.core.CliktCommand
|
|
import com.github.ajalt.clikt.parameters.options.flag
|
|
import com.github.ajalt.clikt.parameters.options.option
|
|
import io.requery.sql.KotlinConfiguration
|
|
import io.requery.sql.SchemaModifier
|
|
import io.requery.sql.TableCreationMode
|
|
import moe.odango.index.di
|
|
import org.kodein.di.instance
|
|
|
|
class DatabaseMigration : CliktCommand(name = "db:create") {
|
|
private val print by option().flag(default = false)
|
|
private val exec by option().flag(default = false)
|
|
|
|
override fun run() {
|
|
val config by di.instance<KotlinConfiguration>()
|
|
val modifier = SchemaModifier(config)
|
|
|
|
if (exec) {
|
|
modifier.createTables(TableCreationMode.CREATE_NOT_EXISTS)
|
|
}
|
|
|
|
if (print) {
|
|
println(modifier.createTablesString(TableCreationMode.CREATE_NOT_EXISTS))
|
|
}
|
|
}
|
|
}
|