This commit is contained in:
Ken
2026-01-19 09:33:35 +07:00
parent 374dc12b2d
commit 70838a4bc1
103 changed files with 16929 additions and 2 deletions

33
models/NotificationLog.js Normal file
View File

@@ -0,0 +1,33 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const NotificationLog = sequelize.define('notification_logs', {
id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
notification_id: { type: DataTypes.UUID, allowNull: false },
user_id: { type: DataTypes.UUID, allowNull: false },
sent_at: { type: DataTypes.DATE },
read_at: { type: DataTypes.DATE },
delivery_status: {
type: DataTypes.ENUM('pending', 'sent', 'delivered', 'failed', 'read'),
defaultValue: 'pending'
},
delivery_channel: {
type: DataTypes.ENUM('in_app', 'email', 'sms', 'push'),
defaultValue: 'in_app'
},
error_message: { type: DataTypes.TEXT },
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
}, {
tableName: 'notification_logs',
timestamps: true,
underscored: true,
indexes: [
{ fields: ['notification_id'] },
{ fields: ['user_id'] },
{ fields: ['delivery_status'] },
{ fields: ['read_at'] },
],
});
module.exports = NotificationLog;