const { DataTypes } = require('sequelize'); const sequelize = require('../config/database'); const ForumPost = sequelize.define('ForumPost', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true }, title: { type: DataTypes.STRING, allowNull: false }, content: { type: DataTypes.TEXT, allowNull: false }, authorId: { type: DataTypes.UUID, allowNull: false, references: { model: 'Users', key: 'id' } }, category: { type: DataTypes.ENUM('item_request', 'technical_support', 'community_resources', 'general_discussion'), allowNull: false, defaultValue: 'general_discussion' }, status: { type: DataTypes.ENUM('open', 'answered', 'closed'), defaultValue: 'open' }, viewCount: { type: DataTypes.INTEGER, defaultValue: 0 }, commentCount: { type: DataTypes.INTEGER, defaultValue: 0 }, isPinned: { type: DataTypes.BOOLEAN, defaultValue: false }, acceptedAnswerId: { type: DataTypes.UUID, allowNull: true, references: { model: 'ForumComments', key: 'id' } }, images: { type: DataTypes.ARRAY(DataTypes.TEXT), allowNull: true, defaultValue: [] }, zipCode: { type: DataTypes.STRING, allowNull: true }, latitude: { type: DataTypes.DECIMAL(10, 8), allowNull: true }, longitude: { type: DataTypes.DECIMAL(11, 8), allowNull: true }, isDeleted: { type: DataTypes.BOOLEAN, defaultValue: false }, deletedBy: { type: DataTypes.UUID, allowNull: true, references: { model: 'Users', key: 'id' } }, deletedAt: { type: DataTypes.DATE, allowNull: true }, deletionReason: { type: DataTypes.TEXT, allowNull: true }, closedBy: { type: DataTypes.UUID, allowNull: true, references: { model: 'Users', key: 'id' } }, closedAt: { type: DataTypes.DATE, allowNull: true } }); module.exports = ForumPost;