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

40
models/Notification.js Normal file
View 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;