forked from UKSOURCE/cms.lams
Adding backend of Student Support, Contact, Request
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
require("dotenv").config();
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
const connectDB = require("../config/database");
|
||||
const StudentSupport = require("../models/studentSupport");
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
/**
|
||||
* Migration: Student Support page content (slug student-support)
|
||||
* Reads data/student-support.json and upserts MongoDB.
|
||||
*/
|
||||
async function migrate() {
|
||||
try {
|
||||
await connectDB();
|
||||
const jsonPath = path.join(__dirname, "../data/student-support.json");
|
||||
const raw = await fs.readFile(jsonPath, "utf8");
|
||||
const data = JSON.parse(raw);
|
||||
await StudentSupport.migrateFromJson(data);
|
||||
console.log("Student Support migration completed successfully");
|
||||
await mongoose.disconnect();
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error("Student Support migration error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
migrate();
|
||||
}
|
||||
|
||||
module.exports = { migrate };
|
||||
Reference in New Issue
Block a user