feat: add isGuest migration script

This commit is contained in:
wancat committed 2024-06-17 20:12:32 +08:00
1 parent 198dcae3f8
commit 443e810471
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)
})