feat: add isGuest migration script

This commit is contained in:
wancat authored and Chen, Tai-Lin committed 2024-07-03 00:34:32 +08:00
1 parent 14cd16b611
commit c30b4a7c6e
2 files changed
+25 -1

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import connectDB, { User } from '@linux-odyssey/models'
async function migrate() {
await connectDB(
process.env.MONGO_URL || 'mongodb://localhost:27017/odyssey-test'
)
await User.updateMany(
{
isGuest: { $exists: false },
},
{ $set: { isGuest: false } }
)
}
migrate()
.then(() => {
console.log('Migration completed')
process.exit(0)
})
.catch((err) => {
console.error(err)
process.exit(1)
})
+2 -1
View File
@@ -9,7 +9,8 @@
"clean": "node dist/cli/clean.js", "clean": "node dist/cli/clean.js",
"build": "tsc -b", "build": "tsc -b",
"dev": "nodemon", "dev": "nodemon",
"build:quests": "node dist/cli/build.js" "build:quests": "node dist/cli/build.js",
"ts-node": "node --loader ts-node/esm"
}, },
"dependencies": { "dependencies": {
"@linux-odyssey/constants": "*", "@linux-odyssey/constants": "*",