forked from UKSOURCE/cms.hailearning.edu.vn
feat(header-menu): add maintenance mode functionality and related UI elements
This commit is contained in:
46
scripts/2026_04_08_200000_add_header_menu_maintainance.js
Normal file
46
scripts/2026_04_08_200000_add_header_menu_maintainance.js
Normal 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 };
|
||||
Reference in New Issue
Block a user