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
198dcae3f8
commit
443e810471
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",
|
"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": "*",
|
||||||
|
|||||||
Reference in new issue
Block a user