forked from UKSOURCE/cms.lams
33 lines
949 B
JavaScript
33 lines
949 B
JavaScript
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 };
|