180 lines
2.2 KiB
JavaScript
180 lines
2.2 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 bug_reports = sequelize.define(
|
|
'bug_reports',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
severity: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"low",
|
|
|
|
|
|
"medium",
|
|
|
|
|
|
"high",
|
|
|
|
|
|
"critical"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"open",
|
|
|
|
|
|
"triaged",
|
|
|
|
|
|
"in_progress",
|
|
|
|
|
|
"fixed",
|
|
|
|
|
|
"wont_fix",
|
|
|
|
|
|
"duplicate"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
build_version: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
reported_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
bug_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.bug_reports.belongsTo(db.users, {
|
|
as: 'reporter',
|
|
foreignKey: {
|
|
name: 'reporterId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.bug_reports.hasMany(db.file, {
|
|
as: 'repro_video',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.bug_reports.getTableName(),
|
|
belongsToColumn: 'repro_video',
|
|
},
|
|
});
|
|
|
|
db.bug_reports.hasMany(db.file, {
|
|
as: 'screenshots',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.bug_reports.getTableName(),
|
|
belongsToColumn: 'screenshots',
|
|
},
|
|
});
|
|
|
|
|
|
db.bug_reports.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.bug_reports.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return bug_reports;
|
|
};
|
|
|
|
|