update
This commit is contained in:
33
models/NotificationLog.js
Normal file
33
models/NotificationLog.js
Normal 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;
|
||||
Reference in New Issue
Block a user