179 lines
2.4 KiB
JavaScript
179 lines
2.4 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 test_run_steps = sequelize.define(
|
|
'test_run_steps',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
step_order_snapshot: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
step_name_snapshot: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
value_text: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
value_number: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
value_boolean: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
value_enum: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"negative",
|
|
|
|
|
|
"positive",
|
|
|
|
|
|
"not_applicable",
|
|
|
|
|
|
"inconclusive"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
recorded_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
test_run_steps.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.test_run_steps.belongsTo(db.test_runs, {
|
|
as: 'test_run',
|
|
foreignKey: {
|
|
name: 'test_runId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.test_run_steps.belongsTo(db.test_steps, {
|
|
as: 'test_step',
|
|
foreignKey: {
|
|
name: 'test_stepId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.test_run_steps.belongsTo(db.users, {
|
|
as: 'recorded_by',
|
|
foreignKey: {
|
|
name: 'recorded_byId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.test_run_steps.hasMany(db.file, {
|
|
as: 'attachments',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.test_run_steps.getTableName(),
|
|
belongsToColumn: 'attachments',
|
|
},
|
|
});
|
|
|
|
|
|
db.test_run_steps.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.test_run_steps.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return test_run_steps;
|
|
};
|
|
|
|
|