feat(header-menu): add maintenance mode functionality and related UI elements

This commit is contained in:
Tống Thành Đạt
2026-04-08 20:57:28 +07:00
parent ffe2f12bb3
commit b6f1b92feb
6 changed files with 135 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
const mongoose = require("mongoose");
const connectDB = require("../config/database");
async function up() {
await connectDB();
try {
const collection = mongoose.connection.db.collection("headermenus");
const result = await collection.updateMany(
{ is_maintainance: { $exists: false } },
{ $set: { is_maintainance: false } },
);
console.log(
`Added is_maintainance=false to ${result.modifiedCount || 0} HeaderMenu document(s).`,
);
} catch (error) {
console.error("Failed to add is_maintainance to HeaderMenu documents:", error);
throw error;
} finally {
await mongoose.disconnect();
}
}
async function down() {
await connectDB();
try {
const collection = mongoose.connection.db.collection("headermenus");
const result = await collection.updateMany(
{ is_maintainance: { $exists: true } },
{ $unset: { is_maintainance: "" } },
);
console.log(
`Removed is_maintainance from ${result.modifiedCount || 0} HeaderMenu document(s).`,
);
} catch (error) {
console.error("Failed to rollback is_maintainance on HeaderMenu documents:", error);
throw error;
} finally {
await mongoose.disconnect();
}
}
module.exports = { up, down };