Created
September 9, 2023 19:13
-
-
Save TheEssem/2c918812361d34361cf17d8877ae10cf to your computer and use it in GitHub Desktop.
An ancient migration script from back when esmBot was switching to MongoDB, uploading here so it isn't lost forever
This file contains hidden or 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
const mongoose = require("mongoose"); | |
mongoose.connect("mongodb://localhost/esmBot"); | |
module.exports = async (client) => { | |
const settings = client.settings; | |
const tags = client.tags; | |
const guildSchema = new mongoose.Schema({ | |
id: String, | |
tags: Map, | |
prefix: String | |
}); | |
const Guild = mongoose.model("Guild", guildSchema); | |
console.log(settings); | |
const indexes = settings.indexes; | |
for (const i of indexes) { | |
const serverSettings = settings.get(i); | |
const serverTags = tags.get(i); | |
console.log(serverTags); | |
const guild = new Guild({ | |
id: i, | |
tags: serverTags, | |
prefix: serverSettings.prefix | |
}); | |
guild.save((error) => { | |
if (error) throw error; | |
console.log(`Migrated guild ${i}`); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment