176 lines
2.3 KiB
JavaScript
176 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 timeline_events = sequelize.define(
|
|
'timeline_events',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
event_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"acquisition",
|
|
|
|
|
|
"security_change",
|
|
|
|
|
|
"loss_event",
|
|
|
|
|
|
"recovery_attempt",
|
|
|
|
|
|
"legal_action",
|
|
|
|
|
|
"scam_attempt",
|
|
|
|
|
|
"press_update",
|
|
|
|
|
|
"verification",
|
|
|
|
|
|
"other"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
event_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
block_height: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
price_usd_snapshot: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
source_url: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
timeline_events.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.timeline_events.belongsTo(db.case_files, {
|
|
as: 'case_file',
|
|
foreignKey: {
|
|
name: 'case_fileId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.timeline_events.hasMany(db.file, {
|
|
as: 'event_images',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.timeline_events.getTableName(),
|
|
belongsToColumn: 'event_images',
|
|
},
|
|
});
|
|
|
|
db.timeline_events.hasMany(db.file, {
|
|
as: 'event_files',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.timeline_events.getTableName(),
|
|
belongsToColumn: 'event_files',
|
|
},
|
|
});
|
|
|
|
|
|
db.timeline_events.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.timeline_events.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return timeline_events;
|
|
};
|
|
|
|
|