diff --git a/src/index.js b/src/index.js index f1e3572..303500f 100644 --- a/src/index.js +++ b/src/index.js @@ -12,22 +12,6 @@ import 'dotenv/config'; // eslint-disable-next-line no-unused-vars import mongoose from './db.js'; -const CommentSchema = new mongoose.Schema({ - message: { - type: String, - require: true, - }, - task: { - type: mongoose.Schema.Types.ObjectId, - ref: 'Task', - }, - user: { - type: mongoose.Schema.Types.ObjectId, - ref: 'User', - }, - createdAt: Date, -}); - const app = express(); const port = process.env.PORT || 3000; @@ -41,20 +25,4 @@ app.use('/tasks', task); app.use('/teams', team); app.use('/invite', invite); -async function migrateCollections(sourceCollectionName, destinationCollectionName) { - try { - const SourceModel = mongoose.model(sourceCollectionName, CommentSchema); - const DestinationModel = mongoose.model(destinationCollectionName, CommentSchema); - - const documents = await SourceModel.find().lean().exec(); - await DestinationModel.insertMany(documents); - - console.log(`Migration complete: ${documents.length} documents migrated.`); - } catch (error) { - console.error('Migration error:', error); - } -} - -await migrateCollections('chats', 'comments'); - app.listen(port, () => console.log(`Server is running on port ${port}`));