const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const Notification = sequelize.define('Notification', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    user_id: {
        type: DataTypes.INTEGER,
        allowNull: false
    },
    title: {
        type: DataTypes.STRING,
        allowNull: false
    },
    message: {
        type: DataTypes.TEXT,
        allowNull: false
    },
    type: {
        type: DataTypes.ENUM('info', 'success', 'warning', 'error'),
        defaultValue: 'info'
    },
    is_read: {
        type: DataTypes.BOOLEAN,
        defaultValue: false
    },
    related_id: {
        type: DataTypes.INTEGER,
        allowNull: true
    },
    related_type: {
        type: DataTypes.STRING, // e.g., 'order', 'user'
        allowNull: true
    }
}, {
    timestamps: true,
    tableName: 'notifications',
    underscored: true
});

module.exports = Notification;
