214 lines
2.3 KiB
JavaScript
214 lines
2.3 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const feedback_reports = sequelize.define(
|
|
'feedback_reports',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
report_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"bug",
|
|
|
|
|
|
"feature_request",
|
|
|
|
|
|
"content_issue",
|
|
|
|
|
|
"security",
|
|
|
|
|
|
"other"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
severity: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"low",
|
|
|
|
|
|
"medium",
|
|
|
|
|
|
"high",
|
|
|
|
|
|
"critical"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
details: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"open",
|
|
|
|
|
|
"triaged",
|
|
|
|
|
|
"in_progress",
|
|
|
|
|
|
"resolved",
|
|
|
|
|
|
"closed"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
app_version: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
platform: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
submitted_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
resolved_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
feedback_reports.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.feedback_reports.belongsTo(db.users, {
|
|
as: 'user',
|
|
foreignKey: {
|
|
name: 'userId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.feedback_reports.hasMany(db.file, {
|
|
as: 'attachments',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.feedback_reports.getTableName(),
|
|
belongsToColumn: 'attachments',
|
|
},
|
|
});
|
|
|
|
|
|
db.feedback_reports.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.feedback_reports.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return feedback_reports;
|
|
};
|
|
|
|
|