40291-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-06-19 14:37:02 +00:00

7757 lines
164 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Organizations = db.organizations;
const Workspaces = db.workspaces;
const WorkspaceMemberships = db.workspace_memberships;
const Cases = db.cases;
const CaseMetrics = db.case_metrics;
const RootCauseNodes = db.root_cause_nodes;
const Solutions = db.solutions;
const ScoringModels = db.scoring_models;
const SolutionScoreRuns = db.solution_score_runs;
const ActionPlans = db.action_plans;
const ActionTasks = db.action_tasks;
const AiRuns = db.ai_runs;
const SolutionTemplates = db.solution_templates;
const AuditEvents = db.audit_events;
const OrganizationsData = [
{
"name": "Grace Hopper",
},
{
"name": "Marie Curie",
},
{
"name": "Ada Lovelace",
},
{
"name": "Grace Hopper",
},
];
const WorkspacesData = [
{
"name": "Grace Hopper",
"slug": "Ada Lovelace",
"industry": "Alan Turing",
"plan": "starter",
"status": "paused",
"trial_ends_at": new Date(Date.now()),
"billing_cycle_starts_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
"name": "Alan Turing",
"slug": "Marie Curie",
"industry": "Marie Curie",
"plan": "free",
"status": "paused",
"trial_ends_at": new Date(Date.now()),
"billing_cycle_starts_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
"name": "Ada Lovelace",
"slug": "Marie Curie",
"industry": "Grace Hopper",
"plan": "business",
"status": "active",
"trial_ends_at": new Date(Date.now()),
"billing_cycle_starts_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
"name": "Marie Curie",
"slug": "Ada Lovelace",
"industry": "Ada Lovelace",
"plan": "business",
"status": "active",
"trial_ends_at": new Date(Date.now()),
"billing_cycle_starts_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const WorkspaceMembershipsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"member_role": "admin",
"membership_status": "suspended",
"invited_at": new Date(Date.now()),
"joined_at": new Date(Date.now()),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"member_role": "admin",
"membership_status": "active",
"invited_at": new Date(Date.now()),
"joined_at": new Date(Date.now()),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"member_role": "member",
"membership_status": "removed",
"invited_at": new Date(Date.now()),
"joined_at": new Date(Date.now()),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"member_role": "member",
"membership_status": "removed",
"invited_at": new Date(Date.now()),
"joined_at": new Date(Date.now()),
// type code here for "relation_one" field
},
];
const CasesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Alan Turing",
"problem_statement": "Grace Hopper",
"status": "draft",
"priority": "medium",
"urgency_level": 4,
"priority_score": 7.0,
"financial_impact_level": "medium",
"estimated_financial_impact": 0.27,
"currency": "Grace Hopper",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"notes": "Marie Curie",
// type code here for "files" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Ada Lovelace",
"problem_statement": "Alan Turing",
"status": "draft",
"priority": "critical",
"urgency_level": 9,
"priority_score": 0.86,
"financial_impact_level": "low",
"estimated_financial_impact": 9.47,
"currency": "Ada Lovelace",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"notes": "Grace Hopper",
// type code here for "files" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Marie Curie",
"problem_statement": "Marie Curie",
"status": "draft",
"priority": "critical",
"urgency_level": 8,
"priority_score": 2.9,
"financial_impact_level": "unknown",
"estimated_financial_impact": 5.88,
"currency": "Marie Curie",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"notes": "Alan Turing",
// type code here for "files" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Ada Lovelace",
"problem_statement": "Grace Hopper",
"status": "in_progress",
"priority": "medium",
"urgency_level": 2,
"priority_score": 9.24,
"financial_impact_level": "high",
"estimated_financial_impact": 2.66,
"currency": "Alan Turing",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"notes": "Alan Turing",
// type code here for "files" field
// type code here for "relation_one" field
},
];
const CaseMetricsData = [
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"baseline_value": 0.84,
"target_value": 6.42,
"current_value": 6.54,
"unit": "Grace Hopper",
"direction": "maintain",
"measured_at": new Date(Date.now()),
"source": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"baseline_value": 2.45,
"target_value": 5.71,
"current_value": 8.89,
"unit": "Grace Hopper",
"direction": "maintain",
"measured_at": new Date(Date.now()),
"source": "Grace Hopper",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"baseline_value": 3.51,
"target_value": 7.53,
"current_value": 7.6,
"unit": "Alan Turing",
"direction": "increase",
"measured_at": new Date(Date.now()),
"source": "Alan Turing",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"baseline_value": 6.72,
"target_value": 2.3,
"current_value": 7.06,
"unit": "Ada Lovelace",
"direction": "increase",
"measured_at": new Date(Date.now()),
"source": "Grace Hopper",
// type code here for "relation_one" field
},
];
const RootCauseNodesData = [
{
// type code here for "relation_one" field
"label": "Ada Lovelace",
"description": "Alan Turing",
"analysis_method": "fishbone",
"category": "people",
// type code here for "relation_one" field
"depth_level": 1,
"contribution_score": 4.87,
"validated": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"label": "Grace Hopper",
"description": "Ada Lovelace",
"analysis_method": "mixed",
"category": "process",
// type code here for "relation_one" field
"depth_level": 4,
"contribution_score": 7.14,
"validated": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"label": "Marie Curie",
"description": "Marie Curie",
"analysis_method": "mixed",
"category": "other",
// type code here for "relation_one" field
"depth_level": 7,
"contribution_score": 1.89,
"validated": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"label": "Alan Turing",
"description": "Alan Turing",
"analysis_method": "fishbone",
"category": "measurement",
// type code here for "relation_one" field
"depth_level": 2,
"contribution_score": 4.9,
"validated": true,
// type code here for "relation_one" field
},
];
const SolutionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Ada Lovelace",
"description": "Ada Lovelace",
"solution_type": "hr",
"impact_score": 1.53,
"efficiency_score": 7.57,
"speed_score": 5.03,
"low_risk_score": 2.38,
"decision_score": 1.13,
"success_probability": 0.77,
"status": "implemented",
"requires_budget": false,
"estimated_cost": 7.49,
"cost_currency": "Ada Lovelace",
"expected_duration_days": 6,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Ada Lovelace",
"description": "Alan Turing",
"solution_type": "hr",
"impact_score": 4.86,
"efficiency_score": 9.39,
"speed_score": 5.63,
"low_risk_score": 0.5,
"decision_score": 1.81,
"success_probability": 6.9,
"status": "implemented",
"requires_budget": true,
"estimated_cost": 5.19,
"cost_currency": "Alan Turing",
"expected_duration_days": 1,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Grace Hopper",
"description": "Alan Turing",
"solution_type": "other",
"impact_score": 8.03,
"efficiency_score": 1.3,
"speed_score": 7.81,
"low_risk_score": 2.3,
"decision_score": 9.08,
"success_probability": 3.99,
"status": "implemented",
"requires_budget": false,
"estimated_cost": 2.71,
"cost_currency": "Alan Turing",
"expected_duration_days": 8,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Grace Hopper",
"description": "Alan Turing",
"solution_type": "finance",
"impact_score": 1.23,
"efficiency_score": 8.15,
"speed_score": 6.24,
"low_risk_score": 4.45,
"decision_score": 8.49,
"success_probability": 4.81,
"status": "selected",
"requires_budget": true,
"estimated_cost": 3.31,
"cost_currency": "Alan Turing",
"expected_duration_days": 3,
// type code here for "relation_one" field
},
];
const ScoringModelsData = [
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"description": "Alan Turing",
"weight_impact": 3.86,
"weight_efficiency": 9.54,
"weight_speed": 1.75,
"weight_low_risk": 0.52,
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Grace Hopper",
"weight_impact": 4.59,
"weight_efficiency": 8.22,
"weight_speed": 8.09,
"weight_low_risk": 0.05,
"is_default": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Grace Hopper",
"weight_impact": 0.98,
"weight_efficiency": 6.25,
"weight_speed": 0.78,
"weight_low_risk": 4.43,
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Marie Curie",
"weight_impact": 6.87,
"weight_efficiency": 8.93,
"weight_speed": 8.85,
"weight_low_risk": 9.13,
"is_default": false,
// type code here for "relation_one" field
},
];
const SolutionScoreRunsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_at": new Date(Date.now()),
"impact_score": 8.76,
"efficiency_score": 3.3,
"speed_score": 0.36,
"low_risk_score": 4.36,
"decision_score": 7.28,
"notes": "Grace Hopper",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_at": new Date(Date.now()),
"impact_score": 9.61,
"efficiency_score": 9.93,
"speed_score": 7.57,
"low_risk_score": 7.07,
"decision_score": 2.5,
"notes": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_at": new Date(Date.now()),
"impact_score": 3.89,
"efficiency_score": 1.15,
"speed_score": 4.17,
"low_risk_score": 1.3,
"decision_score": 1.7,
"notes": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_at": new Date(Date.now()),
"impact_score": 5.1,
"efficiency_score": 0.24,
"speed_score": 9.86,
"low_risk_score": 6.12,
"decision_score": 6.66,
"notes": "Ada Lovelace",
// type code here for "relation_one" field
},
];
const ActionPlansData = [
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"objective": "Alan Turing",
"status": "draft",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"budget": 0.54,
"budget_currency": "Grace Hopper",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"objective": "Ada Lovelace",
"status": "draft",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"budget": 7.87,
"budget_currency": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Alan Turing",
"objective": "Grace Hopper",
"status": "cancelled",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"budget": 7.0,
"budget_currency": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"objective": "Ada Lovelace",
"status": "cancelled",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"budget": 8.22,
"budget_currency": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const ActionTasksData = [
{
// type code here for "relation_one" field
"title": "Alan Turing",
"description": "Grace Hopper",
"status": "doing",
"priority": "critical",
"due_at": new Date(Date.now()),
"day_number": 3,
// type code here for "relation_one" field
"estimated_hours": 1.28,
"actual_hours": 6.18,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"description": "Grace Hopper",
"status": "doing",
"priority": "low",
"due_at": new Date(Date.now()),
"day_number": 7,
// type code here for "relation_one" field
"estimated_hours": 8.94,
"actual_hours": 7.54,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Alan Turing",
"description": "Grace Hopper",
"status": "blocked",
"priority": "medium",
"due_at": new Date(Date.now()),
"day_number": 5,
// type code here for "relation_one" field
"estimated_hours": 5.88,
"actual_hours": 0.28,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"description": "Marie Curie",
"status": "doing",
"priority": "critical",
"due_at": new Date(Date.now()),
"day_number": 1,
// type code here for "relation_one" field
"estimated_hours": 4.41,
"actual_hours": 2.69,
// type code here for "relation_one" field
},
];
const AiRunsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_type": "solution_generation",
"provider": "local",
"model_name": "Alan Turing",
"status": "running",
"started_at": new Date(Date.now()),
"finished_at": new Date(Date.now()),
"input_tokens": 7,
"output_tokens": 3,
"cost": 7.99,
"currency": "Ada Lovelace",
"prompt_text": "Grace Hopper",
"output_text": "Grace Hopper",
"error_message": "Marie Curie",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_type": "full_pipeline",
"provider": "local",
"model_name": "Marie Curie",
"status": "cancelled",
"started_at": new Date(Date.now()),
"finished_at": new Date(Date.now()),
"input_tokens": 3,
"output_tokens": 6,
"cost": 1.5,
"currency": "Alan Turing",
"prompt_text": "Ada Lovelace",
"output_text": "Ada Lovelace",
"error_message": "Marie Curie",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_type": "full_pipeline",
"provider": "local",
"model_name": "Alan Turing",
"status": "succeeded",
"started_at": new Date(Date.now()),
"finished_at": new Date(Date.now()),
"input_tokens": 7,
"output_tokens": 7,
"cost": 0.08,
"currency": "Alan Turing",
"prompt_text": "Grace Hopper",
"output_text": "Marie Curie",
"error_message": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"run_type": "problem_detection",
"provider": "other",
"model_name": "Ada Lovelace",
"status": "cancelled",
"started_at": new Date(Date.now()),
"finished_at": new Date(Date.now()),
"input_tokens": 5,
"output_tokens": 2,
"cost": 1.32,
"currency": "Ada Lovelace",
"prompt_text": "Marie Curie",
"output_text": "Marie Curie",
"error_message": "Alan Turing",
// type code here for "relation_one" field
},
];
const SolutionTemplatesData = [
{
// type code here for "relation_one" field
"title": "Marie Curie",
"description": "Ada Lovelace",
"solution_type": "technology",
"use_case_tags": "Alan Turing",
"is_public": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"description": "Marie Curie",
"solution_type": "technology",
"use_case_tags": "Grace Hopper",
"is_public": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Ada Lovelace",
"description": "Ada Lovelace",
"solution_type": "marketing",
"use_case_tags": "Grace Hopper",
"is_public": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"description": "Marie Curie",
"solution_type": "technology",
"use_case_tags": "Grace Hopper",
"is_public": true,
// type code here for "relation_one" field
},
];
const AuditEventsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "delete",
"entity_name": "Marie Curie",
"entity_record_key": "Ada Lovelace",
"event_at": new Date(Date.now()),
"ip_address": "Alan Turing",
"user_agent": "Grace Hopper",
"details_json": "Alan Turing",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "invite",
"entity_name": "Marie Curie",
"entity_record_key": "Alan Turing",
"event_at": new Date(Date.now()),
"ip_address": "Ada Lovelace",
"user_agent": "Grace Hopper",
"details_json": "Marie Curie",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "create",
"entity_name": "Marie Curie",
"entity_record_key": "Alan Turing",
"event_at": new Date(Date.now()),
"ip_address": "Ada Lovelace",
"user_agent": "Ada Lovelace",
"details_json": "Grace Hopper",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "run_ai",
"entity_name": "Alan Turing",
"entity_record_key": "Marie Curie",
"event_at": new Date(Date.now()),
"ip_address": "Ada Lovelace",
"user_agent": "Grace Hopper",
"details_json": "Ada Lovelace",
// type code here for "relation_one" field
},
];
// Similar logic for "relation_many"
async function associateUserWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User0 = await Users.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (User0?.setOrganization)
{
await
User0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User1 = await Users.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (User1?.setOrganization)
{
await
User1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User2 = await Users.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (User2?.setOrganization)
{
await
User2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (User3?.setOrganization)
{
await
User3.
setOrganization(relatedOrganization3);
}
}
async function associateWorkspaceWithOwner() {
const relatedOwner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Workspace0 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Workspace0?.setOwner)
{
await
Workspace0.
setOwner(relatedOwner0);
}
const relatedOwner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Workspace1 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Workspace1?.setOwner)
{
await
Workspace1.
setOwner(relatedOwner1);
}
const relatedOwner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Workspace2 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Workspace2?.setOwner)
{
await
Workspace2.
setOwner(relatedOwner2);
}
const relatedOwner3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Workspace3 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Workspace3?.setOwner)
{
await
Workspace3.
setOwner(relatedOwner3);
}
}
async function associateWorkspaceWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Workspace0 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Workspace0?.setOrganization)
{
await
Workspace0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Workspace1 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Workspace1?.setOrganization)
{
await
Workspace1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Workspace2 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Workspace2?.setOrganization)
{
await
Workspace2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Workspace3 = await Workspaces.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Workspace3?.setOrganization)
{
await
Workspace3.
setOrganization(relatedOrganization3);
}
}
async function associateWorkspaceMembershipWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const WorkspaceMembership0 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WorkspaceMembership0?.setWorkspace)
{
await
WorkspaceMembership0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const WorkspaceMembership1 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WorkspaceMembership1?.setWorkspace)
{
await
WorkspaceMembership1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const WorkspaceMembership2 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WorkspaceMembership2?.setWorkspace)
{
await
WorkspaceMembership2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const WorkspaceMembership3 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WorkspaceMembership3?.setWorkspace)
{
await
WorkspaceMembership3.
setWorkspace(relatedWorkspace3);
}
}
async function associateWorkspaceMembershipWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WorkspaceMembership0 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WorkspaceMembership0?.setUser)
{
await
WorkspaceMembership0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WorkspaceMembership1 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WorkspaceMembership1?.setUser)
{
await
WorkspaceMembership1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WorkspaceMembership2 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WorkspaceMembership2?.setUser)
{
await
WorkspaceMembership2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WorkspaceMembership3 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WorkspaceMembership3?.setUser)
{
await
WorkspaceMembership3.
setUser(relatedUser3);
}
}
async function associateWorkspaceMembershipWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const WorkspaceMembership0 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WorkspaceMembership0?.setOrganization)
{
await
WorkspaceMembership0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const WorkspaceMembership1 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WorkspaceMembership1?.setOrganization)
{
await
WorkspaceMembership1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const WorkspaceMembership2 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WorkspaceMembership2?.setOrganization)
{
await
WorkspaceMembership2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const WorkspaceMembership3 = await WorkspaceMemberships.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WorkspaceMembership3?.setOrganization)
{
await
WorkspaceMembership3.
setOrganization(relatedOrganization3);
}
}
async function associateCasWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const Cas0 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Cas0?.setWorkspace)
{
await
Cas0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const Cas1 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Cas1?.setWorkspace)
{
await
Cas1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const Cas2 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Cas2?.setWorkspace)
{
await
Cas2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const Cas3 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Cas3?.setWorkspace)
{
await
Cas3.
setWorkspace(relatedWorkspace3);
}
}
async function associateCasWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Cas0 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Cas0?.setCreated_by_user)
{
await
Cas0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Cas1 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Cas1?.setCreated_by_user)
{
await
Cas1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Cas2 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Cas2?.setCreated_by_user)
{
await
Cas2.
setCreated_by_user(relatedCreated_by_user2);
}
const relatedCreated_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Cas3 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Cas3?.setCreated_by_user)
{
await
Cas3.
setCreated_by_user(relatedCreated_by_user3);
}
}
async function associateCasWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Cas0 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Cas0?.setOrganization)
{
await
Cas0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Cas1 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Cas1?.setOrganization)
{
await
Cas1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Cas2 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Cas2?.setOrganization)
{
await
Cas2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Cas3 = await Cases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Cas3?.setOrganization)
{
await
Cas3.
setOrganization(relatedOrganization3);
}
}
async function associateCaseMetricWithCase() {
const relatedCase0 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const CaseMetric0 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CaseMetric0?.setCase)
{
await
CaseMetric0.
setCase(relatedCase0);
}
const relatedCase1 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const CaseMetric1 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CaseMetric1?.setCase)
{
await
CaseMetric1.
setCase(relatedCase1);
}
const relatedCase2 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const CaseMetric2 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CaseMetric2?.setCase)
{
await
CaseMetric2.
setCase(relatedCase2);
}
const relatedCase3 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const CaseMetric3 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CaseMetric3?.setCase)
{
await
CaseMetric3.
setCase(relatedCase3);
}
}
async function associateCaseMetricWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CaseMetric0 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CaseMetric0?.setOrganization)
{
await
CaseMetric0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CaseMetric1 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CaseMetric1?.setOrganization)
{
await
CaseMetric1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CaseMetric2 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CaseMetric2?.setOrganization)
{
await
CaseMetric2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CaseMetric3 = await CaseMetrics.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CaseMetric3?.setOrganization)
{
await
CaseMetric3.
setOrganization(relatedOrganization3);
}
}
async function associateRootCauseNodeWithCase() {
const relatedCase0 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const RootCauseNode0 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RootCauseNode0?.setCase)
{
await
RootCauseNode0.
setCase(relatedCase0);
}
const relatedCase1 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const RootCauseNode1 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RootCauseNode1?.setCase)
{
await
RootCauseNode1.
setCase(relatedCase1);
}
const relatedCase2 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const RootCauseNode2 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RootCauseNode2?.setCase)
{
await
RootCauseNode2.
setCase(relatedCase2);
}
const relatedCase3 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const RootCauseNode3 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RootCauseNode3?.setCase)
{
await
RootCauseNode3.
setCase(relatedCase3);
}
}
async function associateRootCauseNodeWithParent_node() {
const relatedParent_node0 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const RootCauseNode0 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RootCauseNode0?.setParent_node)
{
await
RootCauseNode0.
setParent_node(relatedParent_node0);
}
const relatedParent_node1 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const RootCauseNode1 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RootCauseNode1?.setParent_node)
{
await
RootCauseNode1.
setParent_node(relatedParent_node1);
}
const relatedParent_node2 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const RootCauseNode2 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RootCauseNode2?.setParent_node)
{
await
RootCauseNode2.
setParent_node(relatedParent_node2);
}
const relatedParent_node3 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const RootCauseNode3 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RootCauseNode3?.setParent_node)
{
await
RootCauseNode3.
setParent_node(relatedParent_node3);
}
}
async function associateRootCauseNodeWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const RootCauseNode0 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RootCauseNode0?.setOrganization)
{
await
RootCauseNode0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const RootCauseNode1 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RootCauseNode1?.setOrganization)
{
await
RootCauseNode1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const RootCauseNode2 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RootCauseNode2?.setOrganization)
{
await
RootCauseNode2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const RootCauseNode3 = await RootCauseNodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RootCauseNode3?.setOrganization)
{
await
RootCauseNode3.
setOrganization(relatedOrganization3);
}
}
async function associateSolutionWithCase() {
const relatedCase0 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const Solution0 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Solution0?.setCase)
{
await
Solution0.
setCase(relatedCase0);
}
const relatedCase1 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const Solution1 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Solution1?.setCase)
{
await
Solution1.
setCase(relatedCase1);
}
const relatedCase2 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const Solution2 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Solution2?.setCase)
{
await
Solution2.
setCase(relatedCase2);
}
const relatedCase3 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const Solution3 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Solution3?.setCase)
{
await
Solution3.
setCase(relatedCase3);
}
}
async function associateSolutionWithLinked_root_cause() {
const relatedLinked_root_cause0 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const Solution0 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Solution0?.setLinked_root_cause)
{
await
Solution0.
setLinked_root_cause(relatedLinked_root_cause0);
}
const relatedLinked_root_cause1 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const Solution1 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Solution1?.setLinked_root_cause)
{
await
Solution1.
setLinked_root_cause(relatedLinked_root_cause1);
}
const relatedLinked_root_cause2 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const Solution2 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Solution2?.setLinked_root_cause)
{
await
Solution2.
setLinked_root_cause(relatedLinked_root_cause2);
}
const relatedLinked_root_cause3 = await RootCauseNodes.findOne({
offset: Math.floor(Math.random() * (await RootCauseNodes.count())),
});
const Solution3 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Solution3?.setLinked_root_cause)
{
await
Solution3.
setLinked_root_cause(relatedLinked_root_cause3);
}
}
async function associateSolutionWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Solution0 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Solution0?.setOrganization)
{
await
Solution0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Solution1 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Solution1?.setOrganization)
{
await
Solution1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Solution2 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Solution2?.setOrganization)
{
await
Solution2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Solution3 = await Solutions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Solution3?.setOrganization)
{
await
Solution3.
setOrganization(relatedOrganization3);
}
}
async function associateScoringModelWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const ScoringModel0 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScoringModel0?.setWorkspace)
{
await
ScoringModel0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const ScoringModel1 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScoringModel1?.setWorkspace)
{
await
ScoringModel1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const ScoringModel2 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScoringModel2?.setWorkspace)
{
await
ScoringModel2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const ScoringModel3 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ScoringModel3?.setWorkspace)
{
await
ScoringModel3.
setWorkspace(relatedWorkspace3);
}
}
async function associateScoringModelWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScoringModel0 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScoringModel0?.setOrganization)
{
await
ScoringModel0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScoringModel1 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScoringModel1?.setOrganization)
{
await
ScoringModel1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScoringModel2 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScoringModel2?.setOrganization)
{
await
ScoringModel2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScoringModel3 = await ScoringModels.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ScoringModel3?.setOrganization)
{
await
ScoringModel3.
setOrganization(relatedOrganization3);
}
}
async function associateSolutionScoreRunWithSolution() {
const relatedSolution0 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const SolutionScoreRun0 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionScoreRun0?.setSolution)
{
await
SolutionScoreRun0.
setSolution(relatedSolution0);
}
const relatedSolution1 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const SolutionScoreRun1 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionScoreRun1?.setSolution)
{
await
SolutionScoreRun1.
setSolution(relatedSolution1);
}
const relatedSolution2 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const SolutionScoreRun2 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionScoreRun2?.setSolution)
{
await
SolutionScoreRun2.
setSolution(relatedSolution2);
}
const relatedSolution3 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const SolutionScoreRun3 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionScoreRun3?.setSolution)
{
await
SolutionScoreRun3.
setSolution(relatedSolution3);
}
}
async function associateSolutionScoreRunWithScoring_model() {
const relatedScoring_model0 = await ScoringModels.findOne({
offset: Math.floor(Math.random() * (await ScoringModels.count())),
});
const SolutionScoreRun0 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionScoreRun0?.setScoring_model)
{
await
SolutionScoreRun0.
setScoring_model(relatedScoring_model0);
}
const relatedScoring_model1 = await ScoringModels.findOne({
offset: Math.floor(Math.random() * (await ScoringModels.count())),
});
const SolutionScoreRun1 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionScoreRun1?.setScoring_model)
{
await
SolutionScoreRun1.
setScoring_model(relatedScoring_model1);
}
const relatedScoring_model2 = await ScoringModels.findOne({
offset: Math.floor(Math.random() * (await ScoringModels.count())),
});
const SolutionScoreRun2 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionScoreRun2?.setScoring_model)
{
await
SolutionScoreRun2.
setScoring_model(relatedScoring_model2);
}
const relatedScoring_model3 = await ScoringModels.findOne({
offset: Math.floor(Math.random() * (await ScoringModels.count())),
});
const SolutionScoreRun3 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionScoreRun3?.setScoring_model)
{
await
SolutionScoreRun3.
setScoring_model(relatedScoring_model3);
}
}
async function associateSolutionScoreRunWithRun_by_user() {
const relatedRun_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SolutionScoreRun0 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionScoreRun0?.setRun_by_user)
{
await
SolutionScoreRun0.
setRun_by_user(relatedRun_by_user0);
}
const relatedRun_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SolutionScoreRun1 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionScoreRun1?.setRun_by_user)
{
await
SolutionScoreRun1.
setRun_by_user(relatedRun_by_user1);
}
const relatedRun_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SolutionScoreRun2 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionScoreRun2?.setRun_by_user)
{
await
SolutionScoreRun2.
setRun_by_user(relatedRun_by_user2);
}
const relatedRun_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SolutionScoreRun3 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionScoreRun3?.setRun_by_user)
{
await
SolutionScoreRun3.
setRun_by_user(relatedRun_by_user3);
}
}
async function associateSolutionScoreRunWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionScoreRun0 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionScoreRun0?.setOrganization)
{
await
SolutionScoreRun0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionScoreRun1 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionScoreRun1?.setOrganization)
{
await
SolutionScoreRun1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionScoreRun2 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionScoreRun2?.setOrganization)
{
await
SolutionScoreRun2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionScoreRun3 = await SolutionScoreRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionScoreRun3?.setOrganization)
{
await
SolutionScoreRun3.
setOrganization(relatedOrganization3);
}
}
async function associateActionPlanWithSolution() {
const relatedSolution0 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const ActionPlan0 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionPlan0?.setSolution)
{
await
ActionPlan0.
setSolution(relatedSolution0);
}
const relatedSolution1 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const ActionPlan1 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionPlan1?.setSolution)
{
await
ActionPlan1.
setSolution(relatedSolution1);
}
const relatedSolution2 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const ActionPlan2 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionPlan2?.setSolution)
{
await
ActionPlan2.
setSolution(relatedSolution2);
}
const relatedSolution3 = await Solutions.findOne({
offset: Math.floor(Math.random() * (await Solutions.count())),
});
const ActionPlan3 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionPlan3?.setSolution)
{
await
ActionPlan3.
setSolution(relatedSolution3);
}
}
async function associateActionPlanWithOwner_user() {
const relatedOwner_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionPlan0 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionPlan0?.setOwner_user)
{
await
ActionPlan0.
setOwner_user(relatedOwner_user0);
}
const relatedOwner_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionPlan1 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionPlan1?.setOwner_user)
{
await
ActionPlan1.
setOwner_user(relatedOwner_user1);
}
const relatedOwner_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionPlan2 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionPlan2?.setOwner_user)
{
await
ActionPlan2.
setOwner_user(relatedOwner_user2);
}
const relatedOwner_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionPlan3 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionPlan3?.setOwner_user)
{
await
ActionPlan3.
setOwner_user(relatedOwner_user3);
}
}
async function associateActionPlanWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionPlan0 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionPlan0?.setOrganization)
{
await
ActionPlan0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionPlan1 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionPlan1?.setOrganization)
{
await
ActionPlan1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionPlan2 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionPlan2?.setOrganization)
{
await
ActionPlan2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionPlan3 = await ActionPlans.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionPlan3?.setOrganization)
{
await
ActionPlan3.
setOrganization(relatedOrganization3);
}
}
async function associateActionTaskWithAction_plan() {
const relatedAction_plan0 = await ActionPlans.findOne({
offset: Math.floor(Math.random() * (await ActionPlans.count())),
});
const ActionTask0 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionTask0?.setAction_plan)
{
await
ActionTask0.
setAction_plan(relatedAction_plan0);
}
const relatedAction_plan1 = await ActionPlans.findOne({
offset: Math.floor(Math.random() * (await ActionPlans.count())),
});
const ActionTask1 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionTask1?.setAction_plan)
{
await
ActionTask1.
setAction_plan(relatedAction_plan1);
}
const relatedAction_plan2 = await ActionPlans.findOne({
offset: Math.floor(Math.random() * (await ActionPlans.count())),
});
const ActionTask2 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionTask2?.setAction_plan)
{
await
ActionTask2.
setAction_plan(relatedAction_plan2);
}
const relatedAction_plan3 = await ActionPlans.findOne({
offset: Math.floor(Math.random() * (await ActionPlans.count())),
});
const ActionTask3 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionTask3?.setAction_plan)
{
await
ActionTask3.
setAction_plan(relatedAction_plan3);
}
}
async function associateActionTaskWithAssignee_user() {
const relatedAssignee_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionTask0 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionTask0?.setAssignee_user)
{
await
ActionTask0.
setAssignee_user(relatedAssignee_user0);
}
const relatedAssignee_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionTask1 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionTask1?.setAssignee_user)
{
await
ActionTask1.
setAssignee_user(relatedAssignee_user1);
}
const relatedAssignee_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionTask2 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionTask2?.setAssignee_user)
{
await
ActionTask2.
setAssignee_user(relatedAssignee_user2);
}
const relatedAssignee_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ActionTask3 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionTask3?.setAssignee_user)
{
await
ActionTask3.
setAssignee_user(relatedAssignee_user3);
}
}
async function associateActionTaskWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionTask0 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActionTask0?.setOrganization)
{
await
ActionTask0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionTask1 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActionTask1?.setOrganization)
{
await
ActionTask1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionTask2 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActionTask2?.setOrganization)
{
await
ActionTask2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActionTask3 = await ActionTasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ActionTask3?.setOrganization)
{
await
ActionTask3.
setOrganization(relatedOrganization3);
}
}
async function associateAiRunWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AiRun0 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AiRun0?.setWorkspace)
{
await
AiRun0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AiRun1 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AiRun1?.setWorkspace)
{
await
AiRun1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AiRun2 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AiRun2?.setWorkspace)
{
await
AiRun2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AiRun3 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AiRun3?.setWorkspace)
{
await
AiRun3.
setWorkspace(relatedWorkspace3);
}
}
async function associateAiRunWithCase() {
const relatedCase0 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const AiRun0 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AiRun0?.setCase)
{
await
AiRun0.
setCase(relatedCase0);
}
const relatedCase1 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const AiRun1 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AiRun1?.setCase)
{
await
AiRun1.
setCase(relatedCase1);
}
const relatedCase2 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const AiRun2 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AiRun2?.setCase)
{
await
AiRun2.
setCase(relatedCase2);
}
const relatedCase3 = await Cases.findOne({
offset: Math.floor(Math.random() * (await Cases.count())),
});
const AiRun3 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AiRun3?.setCase)
{
await
AiRun3.
setCase(relatedCase3);
}
}
async function associateAiRunWithTriggered_by_user() {
const relatedTriggered_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AiRun0 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AiRun0?.setTriggered_by_user)
{
await
AiRun0.
setTriggered_by_user(relatedTriggered_by_user0);
}
const relatedTriggered_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AiRun1 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AiRun1?.setTriggered_by_user)
{
await
AiRun1.
setTriggered_by_user(relatedTriggered_by_user1);
}
const relatedTriggered_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AiRun2 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AiRun2?.setTriggered_by_user)
{
await
AiRun2.
setTriggered_by_user(relatedTriggered_by_user2);
}
const relatedTriggered_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AiRun3 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AiRun3?.setTriggered_by_user)
{
await
AiRun3.
setTriggered_by_user(relatedTriggered_by_user3);
}
}
async function associateAiRunWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AiRun0 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AiRun0?.setOrganization)
{
await
AiRun0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AiRun1 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AiRun1?.setOrganization)
{
await
AiRun1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AiRun2 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AiRun2?.setOrganization)
{
await
AiRun2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AiRun3 = await AiRuns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AiRun3?.setOrganization)
{
await
AiRun3.
setOrganization(relatedOrganization3);
}
}
async function associateSolutionTemplateWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const SolutionTemplate0 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionTemplate0?.setWorkspace)
{
await
SolutionTemplate0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const SolutionTemplate1 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionTemplate1?.setWorkspace)
{
await
SolutionTemplate1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const SolutionTemplate2 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionTemplate2?.setWorkspace)
{
await
SolutionTemplate2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const SolutionTemplate3 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionTemplate3?.setWorkspace)
{
await
SolutionTemplate3.
setWorkspace(relatedWorkspace3);
}
}
async function associateSolutionTemplateWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionTemplate0 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SolutionTemplate0?.setOrganization)
{
await
SolutionTemplate0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionTemplate1 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SolutionTemplate1?.setOrganization)
{
await
SolutionTemplate1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionTemplate2 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SolutionTemplate2?.setOrganization)
{
await
SolutionTemplate2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const SolutionTemplate3 = await SolutionTemplates.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SolutionTemplate3?.setOrganization)
{
await
SolutionTemplate3.
setOrganization(relatedOrganization3);
}
}
async function associateAuditEventWithWorkspace() {
const relatedWorkspace0 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AuditEvent0 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditEvent0?.setWorkspace)
{
await
AuditEvent0.
setWorkspace(relatedWorkspace0);
}
const relatedWorkspace1 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AuditEvent1 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditEvent1?.setWorkspace)
{
await
AuditEvent1.
setWorkspace(relatedWorkspace1);
}
const relatedWorkspace2 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AuditEvent2 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditEvent2?.setWorkspace)
{
await
AuditEvent2.
setWorkspace(relatedWorkspace2);
}
const relatedWorkspace3 = await Workspaces.findOne({
offset: Math.floor(Math.random() * (await Workspaces.count())),
});
const AuditEvent3 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditEvent3?.setWorkspace)
{
await
AuditEvent3.
setWorkspace(relatedWorkspace3);
}
}
async function associateAuditEventWithActor_user() {
const relatedActor_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditEvent0 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditEvent0?.setActor_user)
{
await
AuditEvent0.
setActor_user(relatedActor_user0);
}
const relatedActor_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditEvent1 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditEvent1?.setActor_user)
{
await
AuditEvent1.
setActor_user(relatedActor_user1);
}
const relatedActor_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditEvent2 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditEvent2?.setActor_user)
{
await
AuditEvent2.
setActor_user(relatedActor_user2);
}
const relatedActor_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditEvent3 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditEvent3?.setActor_user)
{
await
AuditEvent3.
setActor_user(relatedActor_user3);
}
}
async function associateAuditEventWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditEvent0 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditEvent0?.setOrganization)
{
await
AuditEvent0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditEvent1 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditEvent1?.setOrganization)
{
await
AuditEvent1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditEvent2 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditEvent2?.setOrganization)
{
await
AuditEvent2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditEvent3 = await AuditEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditEvent3?.setOrganization)
{
await
AuditEvent3.
setOrganization(relatedOrganization3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Organizations.bulkCreate(OrganizationsData);
await Workspaces.bulkCreate(WorkspacesData);
await WorkspaceMemberships.bulkCreate(WorkspaceMembershipsData);
await Cases.bulkCreate(CasesData);
await CaseMetrics.bulkCreate(CaseMetricsData);
await RootCauseNodes.bulkCreate(RootCauseNodesData);
await Solutions.bulkCreate(SolutionsData);
await ScoringModels.bulkCreate(ScoringModelsData);
await SolutionScoreRuns.bulkCreate(SolutionScoreRunsData);
await ActionPlans.bulkCreate(ActionPlansData);
await ActionTasks.bulkCreate(ActionTasksData);
await AiRuns.bulkCreate(AiRunsData);
await SolutionTemplates.bulkCreate(SolutionTemplatesData);
await AuditEvents.bulkCreate(AuditEventsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithOrganization(),
await associateWorkspaceWithOwner(),
await associateWorkspaceWithOrganization(),
await associateWorkspaceMembershipWithWorkspace(),
await associateWorkspaceMembershipWithUser(),
await associateWorkspaceMembershipWithOrganization(),
await associateCasWithWorkspace(),
await associateCasWithCreated_by_user(),
await associateCasWithOrganization(),
await associateCaseMetricWithCase(),
await associateCaseMetricWithOrganization(),
await associateRootCauseNodeWithCase(),
await associateRootCauseNodeWithParent_node(),
await associateRootCauseNodeWithOrganization(),
await associateSolutionWithCase(),
await associateSolutionWithLinked_root_cause(),
await associateSolutionWithOrganization(),
await associateScoringModelWithWorkspace(),
await associateScoringModelWithOrganization(),
await associateSolutionScoreRunWithSolution(),
await associateSolutionScoreRunWithScoring_model(),
await associateSolutionScoreRunWithRun_by_user(),
await associateSolutionScoreRunWithOrganization(),
await associateActionPlanWithSolution(),
await associateActionPlanWithOwner_user(),
await associateActionPlanWithOrganization(),
await associateActionTaskWithAction_plan(),
await associateActionTaskWithAssignee_user(),
await associateActionTaskWithOrganization(),
await associateAiRunWithWorkspace(),
await associateAiRunWithCase(),
await associateAiRunWithTriggered_by_user(),
await associateAiRunWithOrganization(),
await associateSolutionTemplateWithWorkspace(),
await associateSolutionTemplateWithOrganization(),
await associateAuditEventWithWorkspace(),
await associateAuditEventWithActor_user(),
await associateAuditEventWithOrganization(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('organizations', null, {});
await queryInterface.bulkDelete('workspaces', null, {});
await queryInterface.bulkDelete('workspace_memberships', null, {});
await queryInterface.bulkDelete('cases', null, {});
await queryInterface.bulkDelete('case_metrics', null, {});
await queryInterface.bulkDelete('root_cause_nodes', null, {});
await queryInterface.bulkDelete('solutions', null, {});
await queryInterface.bulkDelete('scoring_models', null, {});
await queryInterface.bulkDelete('solution_score_runs', null, {});
await queryInterface.bulkDelete('action_plans', null, {});
await queryInterface.bulkDelete('action_tasks', null, {});
await queryInterface.bulkDelete('ai_runs', null, {});
await queryInterface.bulkDelete('solution_templates', null, {});
await queryInterface.bulkDelete('audit_events', null, {});
},
};