Add migrations
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package db.migration
|
||||||
|
|
||||||
|
import dao.DictionaryDao
|
||||||
|
import kotlinx.serialization.decodeFromString
|
||||||
|
import tables.*
|
||||||
|
import org.flywaydb.core.api.migration.BaseJavaMigration
|
||||||
|
import org.flywaydb.core.api.migration.Context
|
||||||
|
import org.jetbrains.exposed.dao.id.EntityID
|
||||||
|
import org.jetbrains.exposed.sql.*
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
class V4__add_lang_code: BaseJavaMigration() {
|
||||||
|
override fun migrate(context: Context?) {
|
||||||
|
transaction {
|
||||||
|
val mapOfCodes = mapOf(1 to "SK",2 to "CZ", 3 to "GB",4 to "NL", 5 to "FR", 6 to "DE", 7 to "IT", 8 to "IT",
|
||||||
|
9 to "HU", 10 to "PL", 11 to "PT", 12 to "RU", 13 to "ES", 14 to "SE" )
|
||||||
|
SchemaUtils.createMissingTablesAndColumns(Languages)
|
||||||
|
for (l in Languages.selectAll()) {
|
||||||
|
val id = l[Languages.id]
|
||||||
|
Languages.update({ Languages.id eq id}) {
|
||||||
|
it[alphaCode] = mapOfCodes[id.value]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package db.migration
|
||||||
|
|
||||||
|
import dao.DictionaryDao
|
||||||
|
import kotlinx.serialization.decodeFromString
|
||||||
|
import tables.*
|
||||||
|
import org.flywaydb.core.api.migration.BaseJavaMigration
|
||||||
|
import org.flywaydb.core.api.migration.Context
|
||||||
|
import org.jetbrains.exposed.dao.id.EntityID
|
||||||
|
import org.jetbrains.exposed.sql.*
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
import service.DatabaseFactory
|
||||||
|
|
||||||
|
class V5__add_indexes: BaseJavaMigration() {
|
||||||
|
override fun migrate(context: Context?) {
|
||||||
|
DatabaseFactory.connectAll()
|
||||||
|
// for ((id,dict) in DatabaseFactory.getDictionaies()) {
|
||||||
|
transaction (1) {
|
||||||
|
SchemaUtils.createMissingTablesAndColumns(Terms)
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user