rup-project/backend/models/Schedule.js

60 lines
1.2 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/db');
const Schedule = sequelize.define('Schedule', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
petId: {
type: DataTypes.INTEGER,
allowNull: false,
comment: 'Reference to Pet table',
},
date: {
type: DataTypes.DATE,
allowNull: false,
comment: 'Schedule start date/time',
},
type: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'general', // 'general', 'important'
},
isCompleted: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
title: {
type: DataTypes.STRING,
allowNull: false,
},
note: {
type: DataTypes.TEXT,
allowNull: true,
},
repeatInterval: {
type: DataTypes.INTEGER,
allowNull: true,
comment: 'Repeat interval (e.g. 1, 2)',
},
repeatUnit: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Repeat unit (day, week, month, year)',
},
isAlarmOn: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
alarmTime: {
type: DataTypes.DATE,
allowNull: true,
},
}, {
timestamps: true, // adds createdAt, updatedAt
});
module.exports = Schedule;