38260-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-07 03:34:22 +00:00

7185 lines
134 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Factions = db.factions;
const UnitTypes = db.unit_types;
const EquipmentTemplates = db.equipment_templates;
const Maps = db.maps;
const TerrainLayers = db.terrain_layers;
const Scenarios = db.scenarios;
const ScenarioFactions = db.scenario_factions;
const Units = db.units;
const UnitLoadouts = db.unit_loadouts;
const MapMarkers = db.map_markers;
const Objectives = db.objectives;
const Orders = db.orders;
const SimulationRuns = db.simulation_runs;
const SimulationTicks = db.simulation_ticks;
const Events = db.events;
const AfterActionReports = db.after_action_reports;
const IntelReports = db.intel_reports;
const Chats = db.chats;
const ChatMessages = db.chat_messages;
const AuditLogs = db.audit_logs;
const FactionsData = [
{
"name": "Blue Coalition",
"code": "BLUE",
"alignment": "hostile",
"color_hex": "#2D6CDF",
"emblem_url": "https://assets.warsim.local/emblems/blue_coalition.png",
"description": "Coalition force focused on stabilization and defense operations.",
},
{
"name": "Red Opposition",
"code": "RED",
"alignment": "hostile",
"color_hex": "#C0392B",
"emblem_url": "https://assets.warsim.local/emblems/red_opposition.png",
"description": "Conventional opposition force with layered defenses and mobile reserves.",
},
{
"name": "Green Neutral Authority",
"code": "GREEN",
"alignment": "neutral",
"color_hex": "#27AE60",
"emblem_url": "https://assets.warsim.local/emblems/green_authority.png",
"description": "Local authority units with limited engagement and area security tasks.",
},
];
const UnitTypesData = [
{
"name": "Mechanized Infantry Platoon",
"domain": "land",
"category": "infantry",
"personnel": 36,
"max_speed_kph": 55,
"fuel_consumption_per_hour": 45,
"attack_power": 62,
"defense_power": 58,
"range_km": 450,
"sensor_range_km": 6,
"carry_capacity_tons": 2.5,
"can_capture": true,
"requires_supply": true,
// type code here for "images" field
"notes": "IFV-equipped platoon suitable for combined arms maneuver.",
},
{
"name": "Main Battle Tank Section",
"domain": "cyber",
"category": "infantry",
"personnel": 12,
"max_speed_kph": 65,
"fuel_consumption_per_hour": 120,
"attack_power": 88,
"defense_power": 80,
"range_km": 380,
"sensor_range_km": 8,
"carry_capacity_tons": 1.0,
"can_capture": true,
"requires_supply": true,
// type code here for "images" field
"notes": "High lethality armored section optimized for direct fire engagements.",
},
{
"name": "Self-Propelled Howitzer Battery",
"domain": "naval",
"category": "artillery",
"personnel": 90,
"max_speed_kph": 60,
"fuel_consumption_per_hour": 160,
"attack_power": 78,
"defense_power": 40,
"range_km": 600,
"sensor_range_km": 12,
"carry_capacity_tons": 8.0,
"can_capture": true,
"requires_supply": true,
// type code here for "images" field
"notes": "Indirect fire battery capable of rapid displacement and sustained fires.",
},
];
const EquipmentTemplatesData = [
{
"name": "5.56mm Service Rifle",
"equipment_class": "ew",
"weight_kg": 3.6,
"effective_range_km": 0.5,
"damage": 12,
"accuracy": 0.7,
"rate_of_fire": 700,
"ammo_capacity": 30,
"is_guided": true,
"requires_line_of_sight": true,
// type code here for "images" field
"description": "Standard infantry rifle for close to mid-range engagements.",
},
{
"name": "ATGM Launcher",
"equipment_class": "manpad",
"weight_kg": 24,
"effective_range_km": 4,
"damage": 85,
"accuracy": 0.78,
"rate_of_fire": 6,
"ammo_capacity": 1,
"is_guided": true,
"requires_line_of_sight": true,
// type code here for "images" field
"description": "Anti-armor guided missile system for standoff engagements.",
},
{
"name": "Manportable Air Defense Missile",
"equipment_class": "radar",
"weight_kg": 18,
"effective_range_km": 5,
"damage": 70,
"accuracy": 0.65,
"rate_of_fire": 3,
"ammo_capacity": 1,
"is_guided": true,
"requires_line_of_sight": true,
// type code here for "images" field
"description": "Shoulder-fired air defense missile for point defense.",
},
];
const MapsData = [
{
"name": "Port Sentinel District",
"location": "Coastal industrial zone",
// type code here for "images" field
"image_width_px": 4096,
"image_height_px": 2304,
"meters_per_pixel": 1.5,
"coordinate_system": "image_xy",
"origin_lat": 0.0,
"origin_lon": 0.0,
"rotation_degrees": 0.0,
"description": "Harbor facilities, container yards, and adjacent residential blocks.",
},
{
"name": "Ridgepass Training Area",
"location": "Mountain valley corridor",
// type code here for "images" field
"image_width_px": 5000,
"image_height_px": 3000,
"meters_per_pixel": 2.0,
"coordinate_system": "utm",
"origin_lat": 0.0,
"origin_lon": 0.0,
"rotation_degrees": 0.0,
"description": "Narrow valley with multiple choke points and high ground observation.",
},
{
"name": "Desert Grid Alpha",
"location": "Arid open terrain",
// type code here for "images" field
"image_width_px": 6000,
"image_height_px": 4000,
"meters_per_pixel": 3.0,
"coordinate_system": "latlon",
"origin_lat": 0.0,
"origin_lon": 0.0,
"rotation_degrees": 0.0,
"description": "Sparse cover, long sightlines, and limited road network.",
},
];
const TerrainLayersData = [
{
// type code here for "relation_one" field
"name": "Primary Roads",
"layer_type": "elevation",
// type code here for "files" field
"opacity": 0.85,
"is_visible_by_default": true,
"notes": "Main supply routes and arterial roads.",
},
{
// type code here for "relation_one" field
"name": "Restricted Zones",
"layer_type": "vegetation",
// type code here for "files" field
"opacity": 0.55,
"is_visible_by_default": true,
"notes": "Port security areas and controlled access points.",
},
{
// type code here for "relation_one" field
"name": "Elevation Contours",
"layer_type": "custom",
// type code here for "files" field
"opacity": 0.7,
"is_visible_by_default": true,
"notes": "Contour bands for high ground and ridgelines.",
},
];
const ScenariosData = [
{
"name": "Operation Harbor Shield",
// type code here for "relation_one" field
// type code here for "relation_one" field
"visibility": "private",
"status": "draft",
"start_time": new Date('2026-02-01T08:00:00Z'),
"end_time": new Date('2026-02-01T18:00:00Z'),
"time_mode": "turn_based",
"turn_length_seconds": 60,
"max_simulation_hours": 8,
"briefing": "Secure port facilities and prevent hostile sabotage while maintaining civilian safety.",
"rules_of_engagement": "Positive identification required. Minimize collateral damage. Protect critical infrastructure.",
// type code here for "files" field
},
{
"name": "Ridgepass Delay Action",
// type code here for "relation_one" field
// type code here for "relation_one" field
"visibility": "team",
"status": "draft",
"start_time": new Date('2026-02-03T06:00:00Z'),
"end_time": new Date('2026-02-03T16:00:00Z'),
"time_mode": "turn_based",
"turn_length_seconds": 90,
"max_simulation_hours": 6,
"briefing": "Conduct delaying defense along valley choke points to allow main force withdrawal.",
"rules_of_engagement": "Engage enemy forces in designated kill zones. Avoid strikes near safe corridors.",
// type code here for "files" field
},
{
"name": "Desert Interdiction Drill",
// type code here for "relation_one" field
// type code here for "relation_one" field
"visibility": "public",
"status": "draft",
"start_time": new Date('2026-02-05T10:00:00Z'),
"end_time": new Date('2026-02-05T20:00:00Z'),
"time_mode": "turn_based",
"turn_length_seconds": 0,
"max_simulation_hours": 10,
"briefing": "Interdict hostile convoy routes using maneuver forces and ISR cueing.",
"rules_of_engagement": "Engage armed vehicles confirmed by ISR. Maintain standoff where feasible.",
// type code here for "files" field
},
];
const ScenarioFactionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"side": "blue",
"callsign_prefix": "BLUE",
"starting_budget": 2500000,
"starting_fuel": 120000,
"starting_ammo": 80000,
"starting_supplies": 90000,
"notes": "Port security and rapid response elements.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"side": "green",
"callsign_prefix": "RED",
"starting_budget": 1800000,
"starting_fuel": 90000,
"starting_ammo": 65000,
"starting_supplies": 70000,
"notes": "Infiltration teams and mobile sabotage units.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"side": "white",
"callsign_prefix": "BLUE",
"starting_budget": 2200000,
"starting_fuel": 100000,
"starting_ammo": 75000,
"starting_supplies": 85000,
"notes": "Defensive screen along ridgeline positions.",
},
];
const UnitsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "1st Mechanized Platoon",
"callsign": "BLUE-ALPHA",
"echelon": "corps",
"readiness": "tired",
"posture": "attacking",
"health": 100,
"morale": 82,
"experience": 65,
"fuel_level": 92,
"ammo_level": 88,
"supply_level": 80,
"is_destroyed": false,
"notes": "Deployed to warehouse district perimeter.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Harbor Air Defense Team",
"callsign": "BLUE-SHIELD",
"echelon": "division",
"readiness": "exhausted",
"posture": "defending",
"health": 100,
"morale": 78,
"experience": 58,
"fuel_level": 85,
"ammo_level": 90,
"supply_level": 75,
"is_destroyed": false,
"notes": "Radar coverage aligned to harbor approaches.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Red ISR UAV Cell",
"callsign": "RED-EYE",
"echelon": "wing",
"readiness": "fresh",
"posture": "retreating",
"health": 100,
"morale": 74,
"experience": 62,
"fuel_level": 95,
"ammo_level": 100,
"supply_level": 70,
"is_destroyed": false,
"notes": "Conducts reconnaissance of port checkpoints.",
},
];
const UnitLoadoutsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"quantity": 30,
"remaining_ammo": 780,
"is_operational": true,
"notes": "Standard rifle loadout distributed across squads.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"quantity": 2,
"remaining_ammo": 6,
"is_operational": true,
"notes": "ATGM teams assigned to overwatch likely armored avenues.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"quantity": 4,
"remaining_ammo": 4,
"is_operational": true,
"notes": "Manportable air defense missiles on alert status.",
},
];
const MapMarkersData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"label": "Alpha Platoon Perimeter",
"marker_type": "waypoint",
"x": 1220.5,
"y": 980.25,
"rotation": 45,
"shape": "square",
"color_hex": "#2D6CDF",
"radius_m": 120,
"is_locked": false,
"placed_at": new Date('2026-02-01T07:45:00Z'),
"details": "Defensive sector covering container yard access road.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"label": "Air Defense Position",
"marker_type": "danger",
"x": 1805.0,
"y": 640.0,
"rotation": 10,
"shape": "icon",
"color_hex": "#2D6CDF",
"radius_m": 90,
"is_locked": true,
"placed_at": new Date('2026-02-01T07:46:00Z'),
"details": "Radar line optimized for harbor approach.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"label": "Red UAV Orbit",
"marker_type": "no_go_zone",
"x": 2100.0,
"y": 520.0,
"rotation": 0,
"shape": "triangle",
"color_hex": "#C0392B",
"radius_m": 250,
"is_locked": true,
"placed_at": new Date('2026-02-01T07:50:00Z'),
"details": "ISR orbit to observe checkpoint movement patterns.",
},
];
const ObjectivesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Secure Main Gate",
"objective_type": "interdict",
"priority": "medium",
"success_threshold": 0.9,
"x": 1950.0,
"y": 720.0,
"radius_m": 120,
"start_time": new Date('2026-02-01T08:00:00Z'),
"due_time": new Date('2026-02-01T18:00:00Z'),
"status": "cancelled",
"description": "Maintain control of the primary port entry checkpoint.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Disrupt Fuel Depot",
"objective_type": "hold",
"priority": "critical",
"success_threshold": 0.75,
"x": 1380.0,
"y": 1120.0,
"radius_m": 140,
"start_time": new Date('2026-02-01T08:30:00Z'),
"due_time": new Date('2026-02-01T14:00:00Z'),
"status": "pending",
"description": "Sabotage fuel storage area to degrade blue mobility.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Hold Choke Point Echo",
"objective_type": "recon",
"priority": "low",
"success_threshold": 0.8,
"x": 2480.0,
"y": 980.0,
"radius_m": 160,
"start_time": new Date('2026-02-03T06:00:00Z'),
"due_time": new Date('2026-02-03T12:00:00Z'),
"status": "cancelled",
"description": "Delay red advance by holding the narrow pass at Echo.",
},
];
const OrdersData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Establish layered defense at container yard",
"order_type": "embark",
"priority": "low",
"target_x": 1240.0,
"target_y": 960.0,
"target_radius_m": 180,
"issued_at": new Date('2026-02-01T07:55:00Z'),
"execute_at": new Date('2026-02-01T08:05:00Z'),
"expires_at": new Date('2026-02-01T12:00:00Z'),
"status": "planned",
"details": "Set primary and alternate positions covering north service road. Coordinate with air defense team for drone alerts.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Activate harbor air picture monitoring",
"order_type": "recon",
"priority": "normal",
"target_x": 1820.0,
"target_y": 650.0,
"target_radius_m": 250,
"issued_at": new Date('2026-02-01T07:56:00Z'),
"execute_at": new Date('2026-02-01T08:00:00Z'),
"expires_at": new Date('2026-02-01T18:00:00Z'),
"status": "failed",
"details": "Maintain radar watch and report any low-altitude contacts approaching port limits.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Advance to Phase Line Copper",
"order_type": "support_fire",
"priority": "urgent",
"target_x": 1700.0,
"target_y": 1900.0,
"target_radius_m": 220,
"issued_at": new Date('2026-02-03T05:50:00Z'),
"execute_at": new Date('2026-02-03T06:10:00Z'),
"expires_at": new Date('2026-02-03T08:30:00Z'),
"status": "executing",
"details": "Use valley floor road, maintain dispersion, and prepare to breach defensive obstacles.",
},
];
const SimulationRunsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Harbor Shield Run 01",
"engine_version": "v1",
"started_at": new Date('2026-02-01T08:00:30Z'),
"finished_at": new Date('2026-02-01T10:15:00Z'),
"status": "failed",
"seed": 142857,
"time_acceleration": 4.0,
"configuration": "Baseline parameters. Deterministic seed. Turn based 60 seconds.",
"summary": "Blue maintained gate control; red sabotage attempt disrupted near fuel depot.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Harbor Shield Run 02",
"engine_version": "v1",
"started_at": new Date('2026-02-01T11:00:00Z'),
"finished_at": new Date('2026-02-01T12:05:00Z'),
"status": "queued",
"seed": 97531,
"time_acceleration": 3.0,
"configuration": "Increased fog of war and reduced sensor ranges.",
"summary": "Run terminated due to invalid marker geometry near restricted zone overlay.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Ridgepass Run A",
"engine_version": "v1",
"started_at": new Date('2026-02-03T06:10:00Z'),
"finished_at": new Date('2026-02-03T08:40:00Z'),
"status": "failed",
"seed": 24680,
"time_acceleration": 2.0,
"configuration": "Turn based 90 seconds with limited resupply.",
"summary": "Engagement developing at Echo choke point; awaiting adjudication input.",
// type code here for "files" field
},
];
const SimulationTicksData = [
{
// type code here for "relation_one" field
"tick_number": 1,
"sim_time": new Date('2026-02-01T08:01:00Z'),
"delta_seconds": 60,
"state_hash": "hsr01-t0001",
"notes": "Initial deployments validated and sensor nets established.",
},
{
// type code here for "relation_one" field
"tick_number": 5,
"sim_time": new Date('2026-02-01T08:05:00Z'),
"delta_seconds": 60,
"state_hash": "hsr01-t0005",
"notes": "Alpha platoon defensive posture set; first ISR detections reported.",
},
{
// type code here for "relation_one" field
"tick_number": 12,
"sim_time": new Date('2026-02-03T06:28:00Z'),
"delta_seconds": 90,
"state_hash": "rpa-t0012",
"notes": "Red armor movement confirmed on valley floor.",
},
];
const EventsData = [
{
// type code here for "relation_one" field
"tick_number": 5,
"occurred_at": new Date('2026-02-01T08:05:20Z'),
"event_type": "system",
"severity": "critical",
// type code here for "relation_one" field
"x": 2100.0,
"y": 520.0,
"message": "UAV track established on checkpoint movement at main gate.",
"data_json": "{ sensor: uav, confidence: 0.72 }",
},
{
// type code here for "relation_one" field
"tick_number": 18,
"occurred_at": new Date('2026-02-01T08:18:45Z'),
"event_type": "weather",
"severity": "critical",
// type code here for "relation_one" field
"x": 1260.0,
"y": 940.0,
"message": "Alpha platoon repositioned to alternate firing points near container stacks.",
"data_json": "{ speed_kph: 12.5, formation: dispersed }",
},
{
// type code here for "relation_one" field
"tick_number": 42,
"occurred_at": new Date('2026-02-01T08:42:10Z'),
"event_type": "order",
"severity": "warning",
// type code here for "relation_one" field
"x": 1340.0,
"y": 1100.0,
"message": "Small arms engagement initiated near fuel depot perimeter.",
"data_json": "{ range_m: 220, enemy_contact: infiltration_team }",
},
];
const AfterActionReportsData = [
{
// type code here for "relation_one" field
"title": "AAR Harbor Shield Run 01",
"generated_at": new Date('2026-02-01T10:20:00Z'),
"classification": "unclassified",
"executive_summary": "Blue successfully defended critical access points and disrupted sabotage attempts.",
"findings": "Early ISR and layered defense reduced red freedom of movement. Air defense posture improved drone awareness.",
"recommendations": "Increase patrol coverage of service tunnels and enhance checkpoint standoff barriers.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "AAR Harbor Shield Run 02",
"generated_at": new Date('2026-02-01T12:10:00Z'),
"classification": "secret",
"executive_summary": "Run failed due to configuration inconsistency affecting restricted zone geometry.",
"findings": "Marker and restricted layer alignment caused invalid collision calculations.",
"recommendations": "Validate terrain overlays on upload and enforce marker bounds checks.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "AAR Ridgepass Run A",
"generated_at": new Date('2026-02-03T08:45:00Z'),
"classification": "unclassified",
"executive_summary": "Scenario paused at decisive engagement point for control cell adjudication.",
"findings": "Choke point defense effective but risk of flanking via high ground remains.",
"recommendations": "Allocate additional reconnaissance to ridge lines and prepare fallback positions.",
// type code here for "files" field
},
];
const IntelReportsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Port Perimeter Anomalies",
"source_type": "osint",
"confidence": "high",
"reported_at": new Date('2026-02-01T07:30:00Z'),
"x": 1320.0,
"y": 1160.0,
"content": "Local workers reported unfamiliar vehicles staging near the fuel depot access road.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Low-altitude Drone Activity",
"source_type": "recon",
"confidence": "high",
"reported_at": new Date('2026-02-01T07:40:00Z'),
"x": 2050.0,
"y": 560.0,
"content": "Intermittent control link signatures consistent with small UAVs detected near harbor approaches.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"title": "Ridgepass Armor Movement",
"source_type": "uav",
"confidence": "medium",
"reported_at": new Date('2026-02-03T06:20:00Z'),
"x": 1600.0,
"y": 2050.0,
"content": "Multiple armored vehicles moving north along valley floor with spaced intervals and smoke discipline.",
// type code here for "files" field
},
];
const ChatsData = [
{
// type code here for "relation_one" field
"name": "Harbor Shield Global",
"channel_type": "team",
},
{
// type code here for "relation_one" field
"name": "Blue Team Net",
"channel_type": "private",
},
{
// type code here for "relation_one" field
"name": "Red Team Net",
"channel_type": "global",
},
];
const ChatMessagesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"sent_at": new Date('2026-02-01T07:58:00Z'),
"message": "All stations confirm readiness for scenario start at 0800.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"sent_at": new Date('2026-02-01T08:02:00Z'),
"message": "Blue units hold positions and report any tunnel access activity.",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"sent_at": new Date('2026-02-01T08:04:00Z'),
"message": "Red team maintain ISR and avoid early exposure near main gate.",
// type code here for "files" field
},
];
const AuditLogsData = [
{
// type code here for "relation_one" field
"action": "logout",
"entity_name": "users",
"record_key": "morgan.hale",
"occurred_at": new Date('2026-02-01T07:20:00Z'),
"ip_address": "10.10.2.15",
"details": "Successful login from operations network.",
},
{
// type code here for "relation_one" field
"action": "update",
"entity_name": "scenarios",
"record_key": "Operation Harbor Shield",
"occurred_at": new Date('2026-02-01T07:40:00Z'),
"ip_address": "10.10.2.22",
"details": "Updated briefing and ROE text prior to start.",
},
{
// type code here for "relation_one" field
"action": "pause_simulation",
"entity_name": "simulation_runs",
"record_key": "Harbor Shield Run 01",
"occurred_at": new Date('2026-02-01T08:00:00Z'),
"ip_address": "10.10.2.31",
"details": "Started simulation with baseline parameters and deterministic seed.",
},
];
// Similar logic for "relation_many"
async function associateTerrainLayerWithMap() {
const relatedMap0 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const TerrainLayer0 = await TerrainLayers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TerrainLayer0?.setMap)
{
await
TerrainLayer0.
setMap(relatedMap0);
}
const relatedMap1 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const TerrainLayer1 = await TerrainLayers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TerrainLayer1?.setMap)
{
await
TerrainLayer1.
setMap(relatedMap1);
}
const relatedMap2 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const TerrainLayer2 = await TerrainLayers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TerrainLayer2?.setMap)
{
await
TerrainLayer2.
setMap(relatedMap2);
}
}
async function associateScenarioWithMap() {
const relatedMap0 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const Scenario0 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Scenario0?.setMap)
{
await
Scenario0.
setMap(relatedMap0);
}
const relatedMap1 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const Scenario1 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Scenario1?.setMap)
{
await
Scenario1.
setMap(relatedMap1);
}
const relatedMap2 = await Maps.findOne({
offset: Math.floor(Math.random() * (await Maps.count())),
});
const Scenario2 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Scenario2?.setMap)
{
await
Scenario2.
setMap(relatedMap2);
}
}
async function associateScenarioWithOwner() {
const relatedOwner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Scenario0 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Scenario0?.setOwner)
{
await
Scenario0.
setOwner(relatedOwner0);
}
const relatedOwner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Scenario1 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Scenario1?.setOwner)
{
await
Scenario1.
setOwner(relatedOwner1);
}
const relatedOwner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Scenario2 = await Scenarios.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Scenario2?.setOwner)
{
await
Scenario2.
setOwner(relatedOwner2);
}
}
async function associateScenarioFactionWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const ScenarioFaction0 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScenarioFaction0?.setScenario)
{
await
ScenarioFaction0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const ScenarioFaction1 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScenarioFaction1?.setScenario)
{
await
ScenarioFaction1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const ScenarioFaction2 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScenarioFaction2?.setScenario)
{
await
ScenarioFaction2.
setScenario(relatedScenario2);
}
}
async function associateScenarioFactionWithFaction() {
const relatedFaction0 = await Factions.findOne({
offset: Math.floor(Math.random() * (await Factions.count())),
});
const ScenarioFaction0 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScenarioFaction0?.setFaction)
{
await
ScenarioFaction0.
setFaction(relatedFaction0);
}
const relatedFaction1 = await Factions.findOne({
offset: Math.floor(Math.random() * (await Factions.count())),
});
const ScenarioFaction1 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScenarioFaction1?.setFaction)
{
await
ScenarioFaction1.
setFaction(relatedFaction1);
}
const relatedFaction2 = await Factions.findOne({
offset: Math.floor(Math.random() * (await Factions.count())),
});
const ScenarioFaction2 = await ScenarioFactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScenarioFaction2?.setFaction)
{
await
ScenarioFaction2.
setFaction(relatedFaction2);
}
}
async function associateUnitWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Unit0 = await Units.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Unit0?.setScenario)
{
await
Unit0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Unit1 = await Units.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Unit1?.setScenario)
{
await
Unit1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Unit2 = await Units.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Unit2?.setScenario)
{
await
Unit2.
setScenario(relatedScenario2);
}
}
async function associateUnitWithScenario_faction() {
const relatedScenario_faction0 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Unit0 = await Units.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Unit0?.setScenario_faction)
{
await
Unit0.
setScenario_faction(relatedScenario_faction0);
}
const relatedScenario_faction1 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Unit1 = await Units.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Unit1?.setScenario_faction)
{
await
Unit1.
setScenario_faction(relatedScenario_faction1);
}
const relatedScenario_faction2 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Unit2 = await Units.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Unit2?.setScenario_faction)
{
await
Unit2.
setScenario_faction(relatedScenario_faction2);
}
}
async function associateUnitWithUnit_type() {
const relatedUnit_type0 = await UnitTypes.findOne({
offset: Math.floor(Math.random() * (await UnitTypes.count())),
});
const Unit0 = await Units.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Unit0?.setUnit_type)
{
await
Unit0.
setUnit_type(relatedUnit_type0);
}
const relatedUnit_type1 = await UnitTypes.findOne({
offset: Math.floor(Math.random() * (await UnitTypes.count())),
});
const Unit1 = await Units.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Unit1?.setUnit_type)
{
await
Unit1.
setUnit_type(relatedUnit_type1);
}
const relatedUnit_type2 = await UnitTypes.findOne({
offset: Math.floor(Math.random() * (await UnitTypes.count())),
});
const Unit2 = await Units.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Unit2?.setUnit_type)
{
await
Unit2.
setUnit_type(relatedUnit_type2);
}
}
async function associateUnitLoadoutWithUnit() {
const relatedUnit0 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const UnitLoadout0 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UnitLoadout0?.setUnit)
{
await
UnitLoadout0.
setUnit(relatedUnit0);
}
const relatedUnit1 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const UnitLoadout1 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UnitLoadout1?.setUnit)
{
await
UnitLoadout1.
setUnit(relatedUnit1);
}
const relatedUnit2 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const UnitLoadout2 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UnitLoadout2?.setUnit)
{
await
UnitLoadout2.
setUnit(relatedUnit2);
}
}
async function associateUnitLoadoutWithEquipment_template() {
const relatedEquipment_template0 = await EquipmentTemplates.findOne({
offset: Math.floor(Math.random() * (await EquipmentTemplates.count())),
});
const UnitLoadout0 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UnitLoadout0?.setEquipment_template)
{
await
UnitLoadout0.
setEquipment_template(relatedEquipment_template0);
}
const relatedEquipment_template1 = await EquipmentTemplates.findOne({
offset: Math.floor(Math.random() * (await EquipmentTemplates.count())),
});
const UnitLoadout1 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UnitLoadout1?.setEquipment_template)
{
await
UnitLoadout1.
setEquipment_template(relatedEquipment_template1);
}
const relatedEquipment_template2 = await EquipmentTemplates.findOne({
offset: Math.floor(Math.random() * (await EquipmentTemplates.count())),
});
const UnitLoadout2 = await UnitLoadouts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UnitLoadout2?.setEquipment_template)
{
await
UnitLoadout2.
setEquipment_template(relatedEquipment_template2);
}
}
async function associateMapMarkerWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const MapMarker0 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MapMarker0?.setScenario)
{
await
MapMarker0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const MapMarker1 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MapMarker1?.setScenario)
{
await
MapMarker1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const MapMarker2 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MapMarker2?.setScenario)
{
await
MapMarker2.
setScenario(relatedScenario2);
}
}
async function associateMapMarkerWithUnit() {
const relatedUnit0 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const MapMarker0 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MapMarker0?.setUnit)
{
await
MapMarker0.
setUnit(relatedUnit0);
}
const relatedUnit1 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const MapMarker1 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MapMarker1?.setUnit)
{
await
MapMarker1.
setUnit(relatedUnit1);
}
const relatedUnit2 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const MapMarker2 = await MapMarkers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MapMarker2?.setUnit)
{
await
MapMarker2.
setUnit(relatedUnit2);
}
}
async function associateObjectiveWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Objective0 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Objective0?.setScenario)
{
await
Objective0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Objective1 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Objective1?.setScenario)
{
await
Objective1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Objective2 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Objective2?.setScenario)
{
await
Objective2.
setScenario(relatedScenario2);
}
}
async function associateObjectiveWithAssigned_to_faction() {
const relatedAssigned_to_faction0 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Objective0 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Objective0?.setAssigned_to_faction)
{
await
Objective0.
setAssigned_to_faction(relatedAssigned_to_faction0);
}
const relatedAssigned_to_faction1 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Objective1 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Objective1?.setAssigned_to_faction)
{
await
Objective1.
setAssigned_to_faction(relatedAssigned_to_faction1);
}
const relatedAssigned_to_faction2 = await ScenarioFactions.findOne({
offset: Math.floor(Math.random() * (await ScenarioFactions.count())),
});
const Objective2 = await Objectives.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Objective2?.setAssigned_to_faction)
{
await
Objective2.
setAssigned_to_faction(relatedAssigned_to_faction2);
}
}
async function associateOrderWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Order0 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Order0?.setScenario)
{
await
Order0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Order1 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Order1?.setScenario)
{
await
Order1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Order2 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Order2?.setScenario)
{
await
Order2.
setScenario(relatedScenario2);
}
}
async function associateOrderWithIssuer() {
const relatedIssuer0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Order0 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Order0?.setIssuer)
{
await
Order0.
setIssuer(relatedIssuer0);
}
const relatedIssuer1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Order1 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Order1?.setIssuer)
{
await
Order1.
setIssuer(relatedIssuer1);
}
const relatedIssuer2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Order2 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Order2?.setIssuer)
{
await
Order2.
setIssuer(relatedIssuer2);
}
}
async function associateOrderWithUnit() {
const relatedUnit0 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Order0 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Order0?.setUnit)
{
await
Order0.
setUnit(relatedUnit0);
}
const relatedUnit1 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Order1 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Order1?.setUnit)
{
await
Order1.
setUnit(relatedUnit1);
}
const relatedUnit2 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Order2 = await Orders.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Order2?.setUnit)
{
await
Order2.
setUnit(relatedUnit2);
}
}
async function associateSimulationRunWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const SimulationRun0 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SimulationRun0?.setScenario)
{
await
SimulationRun0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const SimulationRun1 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SimulationRun1?.setScenario)
{
await
SimulationRun1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const SimulationRun2 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SimulationRun2?.setScenario)
{
await
SimulationRun2.
setScenario(relatedScenario2);
}
}
async function associateSimulationRunWithStarted_by() {
const relatedStarted_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SimulationRun0 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SimulationRun0?.setStarted_by)
{
await
SimulationRun0.
setStarted_by(relatedStarted_by0);
}
const relatedStarted_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SimulationRun1 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SimulationRun1?.setStarted_by)
{
await
SimulationRun1.
setStarted_by(relatedStarted_by1);
}
const relatedStarted_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SimulationRun2 = await SimulationRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SimulationRun2?.setStarted_by)
{
await
SimulationRun2.
setStarted_by(relatedStarted_by2);
}
}
async function associateSimulationTickWithSimulation_run() {
const relatedSimulation_run0 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const SimulationTick0 = await SimulationTicks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SimulationTick0?.setSimulation_run)
{
await
SimulationTick0.
setSimulation_run(relatedSimulation_run0);
}
const relatedSimulation_run1 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const SimulationTick1 = await SimulationTicks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SimulationTick1?.setSimulation_run)
{
await
SimulationTick1.
setSimulation_run(relatedSimulation_run1);
}
const relatedSimulation_run2 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const SimulationTick2 = await SimulationTicks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SimulationTick2?.setSimulation_run)
{
await
SimulationTick2.
setSimulation_run(relatedSimulation_run2);
}
}
async function associateEventWithSimulation_run() {
const relatedSimulation_run0 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const Event0 = await Events.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Event0?.setSimulation_run)
{
await
Event0.
setSimulation_run(relatedSimulation_run0);
}
const relatedSimulation_run1 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const Event1 = await Events.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Event1?.setSimulation_run)
{
await
Event1.
setSimulation_run(relatedSimulation_run1);
}
const relatedSimulation_run2 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const Event2 = await Events.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Event2?.setSimulation_run)
{
await
Event2.
setSimulation_run(relatedSimulation_run2);
}
}
async function associateEventWithUnit() {
const relatedUnit0 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Event0 = await Events.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Event0?.setUnit)
{
await
Event0.
setUnit(relatedUnit0);
}
const relatedUnit1 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Event1 = await Events.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Event1?.setUnit)
{
await
Event1.
setUnit(relatedUnit1);
}
const relatedUnit2 = await Units.findOne({
offset: Math.floor(Math.random() * (await Units.count())),
});
const Event2 = await Events.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Event2?.setUnit)
{
await
Event2.
setUnit(relatedUnit2);
}
}
async function associateAfterActionReportWithSimulation_run() {
const relatedSimulation_run0 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const AfterActionReport0 = await AfterActionReports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AfterActionReport0?.setSimulation_run)
{
await
AfterActionReport0.
setSimulation_run(relatedSimulation_run0);
}
const relatedSimulation_run1 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const AfterActionReport1 = await AfterActionReports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AfterActionReport1?.setSimulation_run)
{
await
AfterActionReport1.
setSimulation_run(relatedSimulation_run1);
}
const relatedSimulation_run2 = await SimulationRuns.findOne({
offset: Math.floor(Math.random() * (await SimulationRuns.count())),
});
const AfterActionReport2 = await AfterActionReports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AfterActionReport2?.setSimulation_run)
{
await
AfterActionReport2.
setSimulation_run(relatedSimulation_run2);
}
}
async function associateIntelReportWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const IntelReport0 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (IntelReport0?.setScenario)
{
await
IntelReport0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const IntelReport1 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (IntelReport1?.setScenario)
{
await
IntelReport1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const IntelReport2 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (IntelReport2?.setScenario)
{
await
IntelReport2.
setScenario(relatedScenario2);
}
}
async function associateIntelReportWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const IntelReport0 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (IntelReport0?.setAuthor)
{
await
IntelReport0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const IntelReport1 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (IntelReport1?.setAuthor)
{
await
IntelReport1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const IntelReport2 = await IntelReports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (IntelReport2?.setAuthor)
{
await
IntelReport2.
setAuthor(relatedAuthor2);
}
}
async function associateChatWithScenario() {
const relatedScenario0 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Chat0 = await Chats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Chat0?.setScenario)
{
await
Chat0.
setScenario(relatedScenario0);
}
const relatedScenario1 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Chat1 = await Chats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Chat1?.setScenario)
{
await
Chat1.
setScenario(relatedScenario1);
}
const relatedScenario2 = await Scenarios.findOne({
offset: Math.floor(Math.random() * (await Scenarios.count())),
});
const Chat2 = await Chats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Chat2?.setScenario)
{
await
Chat2.
setScenario(relatedScenario2);
}
}
async function associateChatMessageWithChat() {
const relatedChat0 = await Chats.findOne({
offset: Math.floor(Math.random() * (await Chats.count())),
});
const ChatMessage0 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ChatMessage0?.setChat)
{
await
ChatMessage0.
setChat(relatedChat0);
}
const relatedChat1 = await Chats.findOne({
offset: Math.floor(Math.random() * (await Chats.count())),
});
const ChatMessage1 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ChatMessage1?.setChat)
{
await
ChatMessage1.
setChat(relatedChat1);
}
const relatedChat2 = await Chats.findOne({
offset: Math.floor(Math.random() * (await Chats.count())),
});
const ChatMessage2 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ChatMessage2?.setChat)
{
await
ChatMessage2.
setChat(relatedChat2);
}
}
async function associateChatMessageWithSender() {
const relatedSender0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage0 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ChatMessage0?.setSender)
{
await
ChatMessage0.
setSender(relatedSender0);
}
const relatedSender1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage1 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ChatMessage1?.setSender)
{
await
ChatMessage1.
setSender(relatedSender1);
}
const relatedSender2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage2 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ChatMessage2?.setSender)
{
await
ChatMessage2.
setSender(relatedSender2);
}
}
async function associateAuditLogWithActor() {
const relatedActor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog0 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditLog0?.setActor)
{
await
AuditLog0.
setActor(relatedActor0);
}
const relatedActor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog1 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditLog1?.setActor)
{
await
AuditLog1.
setActor(relatedActor1);
}
const relatedActor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog2 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditLog2?.setActor)
{
await
AuditLog2.
setActor(relatedActor2);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Factions.bulkCreate(FactionsData);
await UnitTypes.bulkCreate(UnitTypesData);
await EquipmentTemplates.bulkCreate(EquipmentTemplatesData);
await Maps.bulkCreate(MapsData);
await TerrainLayers.bulkCreate(TerrainLayersData);
await Scenarios.bulkCreate(ScenariosData);
await ScenarioFactions.bulkCreate(ScenarioFactionsData);
await Units.bulkCreate(UnitsData);
await UnitLoadouts.bulkCreate(UnitLoadoutsData);
await MapMarkers.bulkCreate(MapMarkersData);
await Objectives.bulkCreate(ObjectivesData);
await Orders.bulkCreate(OrdersData);
await SimulationRuns.bulkCreate(SimulationRunsData);
await SimulationTicks.bulkCreate(SimulationTicksData);
await Events.bulkCreate(EventsData);
await AfterActionReports.bulkCreate(AfterActionReportsData);
await IntelReports.bulkCreate(IntelReportsData);
await Chats.bulkCreate(ChatsData);
await ChatMessages.bulkCreate(ChatMessagesData);
await AuditLogs.bulkCreate(AuditLogsData);
await Promise.all([
// Similar logic for "relation_many"
await associateTerrainLayerWithMap(),
await associateScenarioWithMap(),
await associateScenarioWithOwner(),
await associateScenarioFactionWithScenario(),
await associateScenarioFactionWithFaction(),
await associateUnitWithScenario(),
await associateUnitWithScenario_faction(),
await associateUnitWithUnit_type(),
await associateUnitLoadoutWithUnit(),
await associateUnitLoadoutWithEquipment_template(),
await associateMapMarkerWithScenario(),
await associateMapMarkerWithUnit(),
await associateObjectiveWithScenario(),
await associateObjectiveWithAssigned_to_faction(),
await associateOrderWithScenario(),
await associateOrderWithIssuer(),
await associateOrderWithUnit(),
await associateSimulationRunWithScenario(),
await associateSimulationRunWithStarted_by(),
await associateSimulationTickWithSimulation_run(),
await associateEventWithSimulation_run(),
await associateEventWithUnit(),
await associateAfterActionReportWithSimulation_run(),
await associateIntelReportWithScenario(),
await associateIntelReportWithAuthor(),
await associateChatWithScenario(),
await associateChatMessageWithChat(),
await associateChatMessageWithSender(),
await associateAuditLogWithActor(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('factions', null, {});
await queryInterface.bulkDelete('unit_types', null, {});
await queryInterface.bulkDelete('equipment_templates', null, {});
await queryInterface.bulkDelete('maps', null, {});
await queryInterface.bulkDelete('terrain_layers', null, {});
await queryInterface.bulkDelete('scenarios', null, {});
await queryInterface.bulkDelete('scenario_factions', null, {});
await queryInterface.bulkDelete('units', null, {});
await queryInterface.bulkDelete('unit_loadouts', null, {});
await queryInterface.bulkDelete('map_markers', null, {});
await queryInterface.bulkDelete('objectives', null, {});
await queryInterface.bulkDelete('orders', null, {});
await queryInterface.bulkDelete('simulation_runs', null, {});
await queryInterface.bulkDelete('simulation_ticks', null, {});
await queryInterface.bulkDelete('events', null, {});
await queryInterface.bulkDelete('after_action_reports', null, {});
await queryInterface.bulkDelete('intel_reports', null, {});
await queryInterface.bulkDelete('chats', null, {});
await queryInterface.bulkDelete('chat_messages', null, {});
await queryInterface.bulkDelete('audit_logs', null, {});
},
};