Files
2025-11-06 11:08:59 +01:00

69 lines
1.4 KiB
JavaScript

module.exports = (sequelize, DataTypes) => {
const Feedback = sequelize.define('Feedback', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
user_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'users',
key: 'id'
}
},
message_id: {
type: DataTypes.UUID,
allowNull: true,
references: {
model: 'messages',
key: 'id'
}
},
feedback_type: {
type: DataTypes.ENUM('positive', 'negative', 'correction', 'suggestion'),
allowNull: false
},
rating: {
type: DataTypes.INTEGER,
allowNull: true,
validate: {
min: 1,
max: 5
}
},
comment: {
type: DataTypes.TEXT,
allowNull: true
},
corrected_content: {
type: DataTypes.TEXT,
allowNull: true
},
is_processed: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
processing_notes: {
type: DataTypes.TEXT,
allowNull: true
},
metadata: {
type: DataTypes.JSONB,
defaultValue: {}
}
}, {
tableName: 'feedback',
indexes: [
{ fields: ['user_id'] },
{ fields: ['message_id'] },
{ fields: ['feedback_type'] },
{ fields: ['is_processed'] },
{ fields: ['created_at'] }
]
});
return Feedback;
};