summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorCadence Ember <cadence@disroot.org>2023-10-01 01:24:05 +1300
committerCadence Ember <cadence@disroot.org>2023-10-01 01:26:42 +1300
commit1d99b91ef7b702fa5ff9896f971e7bacc1d7d984 (patch)
treefe253637c37b2a30c2e4c221841dd1b0828dd7d5 /scripts
parentAutodetect mime type for m->d stickers (diff)
downloadout-of-your-element-1d99b91ef7b702fa5ff9896f971e7bacc1d7d984.tar.xz
Add database migrations
Diffstat (limited to 'scripts')
-rw-r--r--scripts/migrate-from-old-bridge.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/migrate-from-old-bridge.js b/scripts/migrate-from-old-bridge.js

index 84daad7..aec345d 100644 --- a/scripts/migrate-from-old-bridge.js +++ b/scripts/migrate-from-old-bridge.js
@@ -20,7 +20,7 @@ const newAT = reg.as_token const oldDB = new sqlite(reg.old_bridge.database) const db = new sqlite("db/ooye.db") -db.exec(`CREATE TABLE IF NOT EXISTS migration ( +db.exec(`CREATE TABLE IF NOT EXISTS half_shot_migration ( discord_channel TEXT NOT NULL, migrated INTEGER NOT NULL, PRIMARY KEY("discord_channel") @@ -69,7 +69,7 @@ async function migrateGuild(guild) { const spaceID = await createSpace.syncSpace(guild) let oldRooms = oldDB.prepare("SELECT matrix_id, discord_guild, discord_channel FROM room_entries INNER JOIN remote_room_data ON remote_id = room_id WHERE discord_guild = ?").all(guild.id) - const migrated = db.prepare("SELECT discord_channel FROM migration WHERE migrated = 1").pluck().all() + const migrated = db.prepare("SELECT discord_channel FROM half_shot_migration WHERE migrated = 1").pluck().all() oldRooms = oldRooms.filter(row => discord.channels.has(row.discord_channel) && !migrated.includes(row.discord_channel)) console.log("Found these rooms which can be migrated:") console.log(oldRooms) @@ -128,7 +128,7 @@ async function migrateGuild(guild) { await createRoom.syncRoom(row.discord_channel) console.log(`-- -- Finished syncing`) - db.prepare("INSERT INTO migration (discord_channel, migrated) VALUES (?, 1)").run(channel.id) + db.prepare("INSERT INTO half_shot_migration (discord_channel, migrated) VALUES (?, 1)").run(channel.id) } // Step 5: Call syncSpace to make sure everything is up to date