Adding backend of Student Support, Contact, Request

This commit is contained in:
2026-04-20 16:22:37 +07:00
parent fab72e86a6
commit ac5fa14c97
23 changed files with 3167 additions and 2324 deletions
+33
View File
@@ -0,0 +1,33 @@
require("dotenv").config();
const fs = require("fs").promises;
const path = require("path");
const connectDB = require("../config/database");
const Contact = require("../models/contact");
const mongoose = require("mongoose");
/**
* Migration: Contact page content (slug: contact)
* Reads data/contact.json and upserts into MongoDB.
* Idempotent — safe to re-run.
*/
async function migrate() {
try {
await connectDB();
const jsonPath = path.join(__dirname, "../data/contact.json");
const raw = await fs.readFile(jsonPath, "utf8");
const data = JSON.parse(raw);
await Contact.migrateFromJson(data);
console.log("Contact migration completed successfully");
await mongoose.disconnect();
process.exit(0);
} catch (error) {
console.error("Contact migration error:", error);
process.exit(1);
}
}
if (require.main === module) {
migrate();
}
module.exports = { migrate };