-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a410a60
commit 8be1560
Showing
2 changed files
with
15 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 15 additions & 17 deletions
32
src/main/kotlin/org/hyacinthbots/lilybot/database/migrations/config/configV5.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
@file:Suppress("DEPRECATION_ERROR") | ||
@file:Suppress("DEPRECATION_ERROR", "UnusedPrivateMember", "UNUSED_PARAMETER", "RedundantSuspendModifier") | ||
|
||
package org.hyacinthbots.lilybot.database.migrations.config | ||
|
||
import org.hyacinthbots.lilybot.database.entities.UtilityConfigData | ||
import org.hyacinthbots.lilybot.database.entities.UtilityConfigDataOld | ||
import org.litote.kmongo.coroutine.CoroutineDatabase | ||
|
||
suspend fun configV5(db: CoroutineDatabase) { | ||
val collection = db.getCollection<UtilityConfigDataOld>("utilityConfigData") | ||
val oldConfigs = collection.find().toList() | ||
val newConfigs = mutableListOf<UtilityConfigData>() | ||
|
||
oldConfigs.forEach { | ||
newConfigs.add(UtilityConfigData(it.guildId, it.utilityLogChannel)) | ||
} | ||
|
||
db.dropCollection("utilityConfigData") | ||
db.createCollection("utilityConfigData") | ||
|
||
with(db.getCollection<UtilityConfigData>("utilityConfigData")) { | ||
insertMany(newConfigs) | ||
} | ||
// val collection = db.getCollection<UtilityConfigDataOld>("utilityConfigData") | ||
// val oldConfigs = collection.find().toList() | ||
// val newConfigs = mutableListOf<UtilityConfigData>() | ||
// | ||
// oldConfigs.forEach { | ||
// newConfigs.add(UtilityConfigData(it.guildId, it.utilityLogChannel)) | ||
// } | ||
// | ||
// db.dropCollection("utilityConfigData") | ||
// db.createCollection("utilityConfigData") | ||
// | ||
// with(db.getCollection<UtilityConfigData>("utilityConfigData")) { | ||
// insertMany(newConfigs) | ||
// } | ||
} |