require("dotenv").config(); const { ActivityLog, User } = require("./backend/models"); async function createTestLog() { try { // Найти админа const admin = await User.findOne({ where: { role: "admin" } }); if (!admin) { console.log("Admin not found"); return; } // Создать тестовую запись лога const log = await ActivityLog.create({ userId: admin.id, action: "Тестовое действие", details: "Это тестовая запись лога для проверки системы", timestamp: new Date(), }); console.log("Test log created:", log.toJSON()); // Получить все логи const logs = await ActivityLog.findAll({ include: [{ model: User, attributes: ["username", "role"] }], order: [["timestamp", "DESC"]], }); console.log("\nAll logs:"); logs.forEach((log) => { console.log( `- ${log.User.username} (${log.User.role}): ${log.action} - ${log.details}` ); }); } catch (error) { console.error("Error:", error); } } createTestLog();