update
All checks were successful
Deploy to Production / deploy (push) Successful in 20s

This commit is contained in:
vuongps38770
2026-02-28 20:00:38 +07:00
parent f96833a7e4
commit 72283443ab
15 changed files with 972 additions and 318 deletions

View File

@@ -0,0 +1,34 @@
const { Context } = require('../models');
const { Op } = require('sequelize');
const { sequelize } = require('../config/database');
async function migrate() {
try {
await sequelize.authenticate();
console.log('✅ Kết nối database thành công.');
const fromDate = new Date('2026-02-28T09:00:00Z');
console.log(`🔍 Tìm kiếm các context có status = 6 và update từ ${fromDate.toISOString()} trở đi...`);
const [affectedCount] = await Context.update(
{ status: 5 },
{
where: {
status: 6,
updated_at: {
[Op.gte]: fromDate
}
}
}
);
console.log(`✅ Đã cập nhật thành công ${affectedCount} bản ghi từ status 6 sang status 5.`);
process.exit(0);
} catch (error) {
console.error('❌ Lỗi khi migration:', error);
process.exit(1);
}
}
migrate();