diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-25 18:24:21 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-25 23:35:18 +1000 |
commit | 0d23eaba09a4878520bf346af4cead90d76829fc (patch) | |
tree | d930eacceff0b407b44abe55f01d8e3c5dfbfa34 /util/scripts | |
parent | Allow edited_timestamp to passthrough in handleMessage (diff) | |
download | server-0d23eaba09a4878520bf346af4cead90d76829fc.tar.xz |
Refactor to mono-repo + upgrade packages
Diffstat (limited to 'util/scripts')
-rw-r--r-- | util/scripts/migrate_db_engine.js | 109 | ||||
-rw-r--r-- | util/scripts/rights.js | 20 |
2 files changed, 0 insertions, 129 deletions
diff --git a/util/scripts/migrate_db_engine.js b/util/scripts/migrate_db_engine.js deleted file mode 100644 index 79e9d86f..00000000 --- a/util/scripts/migrate_db_engine.js +++ /dev/null @@ -1,109 +0,0 @@ -const { config } = require("dotenv"); -config(); -const { createConnection } = require("typeorm"); -const { initDatabase } = require("../../dist/util/Database"); -require("missing-native-js-functions"); -const { - Application, - Attachment, - Ban, - Channel, - ConfigEntity, - ConnectedAccount, - Emoji, - Guild, - Invite, - Member, - Message, - ReadState, - Recipient, - Relationship, - Role, - Sticker, - Team, - TeamMember, - Template, - User, - VoiceState, - Webhook, -} = require("../../dist/entities/index"); - -async function main() { - if (!process.env.TO) throw new Error("TO database env connection string not set"); - - // manually arrange them because of foreign keys - const entities = [ - ConfigEntity, - User, - Guild, - Channel, - Invite, - Role, - Ban, - Application, - Emoji, - ConnectedAccount, - Member, - ReadState, - Recipient, - Relationship, - Sticker, - Team, - TeamMember, - Template, - VoiceState, - Webhook, - Message, - Attachment, - ]; - - const oldDB = await initDatabase(); - - const type = process.env.TO.includes("://") ? process.env.TO.split(":")[0]?.replace("+srv", "") : "sqlite"; - const isSqlite = type.includes("sqlite"); - - // @ts-ignore - const newDB = await createConnection({ - type, - url: isSqlite ? undefined : process.env.TO, - database: isSqlite ? process.env.TO : undefined, - entities, - name: "new", - synchronize: true, - }); - let i = 0; - - try { - for (const entity of entities) { - const entries = await oldDB.manager.find(entity); - - // @ts-ignore - console.log("migrating " + entries.length + " " + entity.name + " ..."); - - for (const entry of entries) { - console.log(i++); - - try { - await newDB.manager.insert(entity, entry); - } catch (error) { - try { - if (!entry.id) throw new Error("object doesn't have a unique id: " + entry); - await newDB.manager.update(entity, { id: entry.id }, entry); - } catch (error) { - console.error("couldn't migrate " + i + " " + entity.name, error); - } - } - } - - // @ts-ignore - console.log("migrated " + entries.length + " " + entity.name); - } - } catch (error) { - console.error(error.message); - } - - console.log("SUCCESS migrated all data"); - await newDB.close(); -} - -main().caught(); diff --git a/util/scripts/rights.js b/util/scripts/rights.js deleted file mode 100644 index 289071f6..00000000 --- a/util/scripts/rights.js +++ /dev/null @@ -1,20 +0,0 @@ -const { Rights } = require(".."); - -const allRights = new Rights(1).bitfield; -console.log(`All rights:`, allRights); - -var discordLike = allRights; -discordLike -= Rights.FLAGS.OPERATOR; -discordLike -= Rights.FLAGS.MANAGE_APPLICATIONS; -discordLike -= Rights.FLAGS.MANAGE_GUILDS; -discordLike -= Rights.FLAGS.MANAGE_MESSAGES; -discordLike -= Rights.FLAGS.MANAGE_RATE_LIMITS; -discordLike -= Rights.FLAGS.MANAGE_ROUTING; -discordLike -= Rights.FLAGS.MANAGE_TICKETS; -discordLike -= Rights.FLAGS.MANAGE_USERS; -discordLike -= Rights.FLAGS.ADD_MEMBERS; -discordLike -= Rights.FLAGS.BYPASS_RATE_LIMITS; -discordLike -= Rights.FLAGS.CREDITABLE; -discordLike -= Rights.FLAGS.MANAGE_GUILD_DIRECTORY; -discordLike -= Rights.FLAGS.SEND_BACKDATED_EVENTS; -console.log(`Discord.com-like rights:`, discordLike); \ No newline at end of file |