Skip to content

Commit

Permalink
Remove Old Log-uploading DB Code
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Aug 15, 2023
1 parent a410a60 commit 8be1560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,6 @@ data class ModerationConfigData(
val publicLogging: Boolean?,
)

/**
* The data for miscellaneous configuration. The miscellaneous config stores the data for enabling or disabling log
* uploading.
*
* @property guildId The ID of the guild the config is for
* @property disableLogUploading If log uploading is enabled or not
* @property utilityLogChannel The channel to log various utility actions too
* @since 4.0.0
*/
@Deprecated(
"Replaced by org.hyacinthbots.database.entities.UtilityConfigData",
ReplaceWith("UtilityConfigData", "import org.hyacinthbots.lilybot.database.entities.UtilityConfigData"),
DeprecationLevel.ERROR
)
@Serializable
data class UtilityConfigDataOld(
val guildId: Snowflake,
val disableLogUploading: Boolean,
val utilityLogChannel: Snowflake?
)

/**
* The data for miscellaneous configuration. The miscellaneous config stores the data for enabling or disabling log
* uploading.
Expand Down
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)
// }
}

0 comments on commit 8be1560

Please sign in to comment.