mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add isGuest migration script
This commit is contained in:
1 parent
14cd16b611
commit
c30b4a7c6e
2 files changed
+25
-1
No files matched your search
@@ -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
@@ -9,7 +9,8 @@
|
||||
"clean": "node dist/cli/clean.js",
|
||||
"build": "tsc -b",
|
||||
"dev": "nodemon",
|
||||
"build:quests": "node dist/cli/build.js"
|
||||
"build:quests": "node dist/cli/build.js",
|
||||
"ts-node": "node --loader ts-node/esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@linux-odyssey/constants": "*",
|
||||
|
||||
Reference in new issue
Block a user