HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/good-life-be/models/Event.js
import { DataTypes, Sequelize } from 'sequelize';
import sequelize from '../config/sequelize-config.js';

const Event = sequelize.define(
  'events',
  {
    id: {
      primaryKey: true,
      type: DataTypes.INTEGER,
      autoIncrement: true,
    },
    user_id: {
      type: DataTypes.UUID,
      allowNull: false, // Assuming the user must be associated with the event
    },
    date: {
      type: DataTypes.DATEONLY, // Store the date as a date only (YYYY-MM-DD)
      allowNull: false,
    },
    event_title: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    event_description: {
      type: DataTypes.TEXT,
      allowNull: false,
    },
    event_name: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    start_time: {
      type: DataTypes.TIME,
      allowNull: false,
    },
    end_time: {
      type: DataTypes.TIME,
      allowNull: false,
    },
    recurring: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      defaultValue: false,
    },
    recurrence_pattern: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    category: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    subCategory: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    ai_activity: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
    },
    ai_suggested_activity: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    bufferTime: {
      type: DataTypes.INTEGER,
      allowNull: true,
    },
    conflict: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      defaultValue: false,
    },
    conflict_reason: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    is_vacation_event: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      defaultValue: false,
    },
    status: {
      type: DataTypes.ENUM('active', 'deleted'),
      allowNull: false, // You can set your own status types like 'active', 'completed', etc.
      defaultValue: 'active',
    },
    createdAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    updatedAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
      onUpdate: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    is_visible: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      defaultValue: true,
    },
  },
  {
    timestamps: true,
  }
);

Event.associate = (models) => {
  Event.belongsTo(models.user, {
    foreignKey: 'user_id',
  });
};

export default Event;