update
This commit is contained in:
40
models/Notification.js
Normal file
40
models/Notification.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const Notification = sequelize.define('notifications', {
|
||||
id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
|
||||
school_id: { type: DataTypes.UUID },
|
||||
title: { type: DataTypes.STRING(255), allowNull: false },
|
||||
content: { type: DataTypes.TEXT },
|
||||
notification_type: {
|
||||
type: DataTypes.ENUM('announcement', 'event', 'emergency', 'reminder', 'grade_update', 'attendance_alert'),
|
||||
defaultValue: 'announcement'
|
||||
},
|
||||
priority: {
|
||||
type: DataTypes.ENUM('low', 'normal', 'high', 'urgent'),
|
||||
defaultValue: 'normal'
|
||||
},
|
||||
target_role: { type: DataTypes.STRING(50) },
|
||||
target_users: { type: DataTypes.JSON },
|
||||
scheduled_at: { type: DataTypes.DATE },
|
||||
sent_at: { type: DataTypes.DATE },
|
||||
created_by: { type: DataTypes.UUID },
|
||||
status: {
|
||||
type: DataTypes.ENUM('draft', 'scheduled', 'sent', 'cancelled'),
|
||||
defaultValue: 'draft'
|
||||
},
|
||||
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||
}, {
|
||||
tableName: 'notifications',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{ fields: ['school_id'] },
|
||||
{ fields: ['notification_type'] },
|
||||
{ fields: ['status'] },
|
||||
{ fields: ['scheduled_at'] },
|
||||
],
|
||||
});
|
||||
|
||||
module.exports = Notification;
|
||||
Reference in New Issue
Block a user