





















const db = require('../models');
const Users = db.users;






const Plants = db.plants;

const WorkCenters = db.work_centers;

const Machines = db.machines;

const MachineEvents = db.machine_events;

const Uoms = db.uoms;

const Items = db.items;

const Warehouses = db.warehouses;

const Locations = db.locations;

const Suppliers = db.suppliers;

const Customers = db.customers;

const Boms = db.boms;

const BomLines = db.bom_lines;

const Routings = db.routings;

const RoutingOperations = db.routing_operations;

const ProductionOrders = db.production_orders;

const ProductionOperations = db.production_operations;

const MaterialRequirements = db.material_requirements;

const Lots = db.lots;

const SerialNumbers = db.serial_numbers;

const InventoryTransactions = db.inventory_transactions;

const Inspections = db.inspections;

const InspectionResults = db.inspection_results;

const Nonconformances = db.nonconformances;

const QualityHolds = db.quality_holds;

const MaintenanceWorkOrders = db.maintenance_work_orders;

const Documents = db.documents;







const PlantsData = [
    
    {
    
        
        
            
                "name": "North Plant",
            
        
    
        
        
            
                "code": "NP01",
            
        
    
        
        
            
                "address": "100 Industrial Way, Dayton, OH",
            
        
    
        
        
            
                "timezone": "America/New_York",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "South Plant",
            
        
    
        
        
            
                "code": "SP01",
            
        
    
        
        
            
                "address": "450 Foundry Rd, Chattanooga, TN",
            
        
    
        
        
            
                "timezone": "America/New_York",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "West Plant",
            
        
    
        
        
            
                "code": "WP01",
            
        
    
        
        
            
                "address": "22 Manufacturing Blvd, Reno, NV",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const WorkCentersData = [
    
    {
    
        
        
            
                "name": "CNC Cell A",
            
        
    
        
        
            
                "code": "WC-CNC-A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "3-axis CNC machining cell",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Assembly Line 1",
            
        
    
        
        
            
                "code": "WC-ASM-1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Primary mechanical assembly line",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Paint Booth",
            
        
    
        
        
            
                "code": "WC-PNT-1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Powder coat and curing area",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const MachinesData = [
    
    {
    
        
        
            
                "name": "Haas VF2 01",
            
        
    
        
        
            
                "asset_tag": "CNC-0001",
            
        
    
        
        
            
                "serial_number": "HVF201A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "idle",
            
        
    
        
        
            
                "ideal_cycle_time_seconds": 48.5,
            
        
    
        
        
            
                "commissioned_at": new Date('2023-02-15T09:00:00Z'),
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Haas VF2 02",
            
        
    
        
        
            
                "asset_tag": "CNC-0002",
            
        
    
        
        
            
                "serial_number": "HVF202B",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "down",
            
        
    
        
        
            
                "ideal_cycle_time_seconds": 49.0,
            
        
    
        
        
            
                "commissioned_at": new Date('2023-03-20T09:00:00Z'),
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Torque Press 10T",
            
        
    
        
        
            
                "asset_tag": "ASM-0010",
            
        
    
        
        
            
                "serial_number": "TP10T77",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "offline",
            
        
    
        
        
            
                "ideal_cycle_time_seconds": 22.0,
            
        
    
        
        
            
                "commissioned_at": new Date('2022-10-01T09:00:00Z'),
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const MachineEventsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "production_run",
            
        
    
        
        
            
                "reason_code": "setup",
            
        
    
        
        
            
                "started_at": new Date('2026-05-20T07:00:00Z'),
            
        
    
        
        
            
                "ended_at": new Date('2026-05-20T11:30:00Z'),
            
        
    
        
        
            
                "duration_minutes": 270,
            
        
    
        
        
            
                "notes": "Machining run for PO-10045",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "note",
            
        
    
        
        
            
                "reason_code": "setup",
            
        
    
        
        
            
                "started_at": new Date('2026-05-21T13:10:00Z'),
            
        
    
        
        
            
                "ended_at": new Date('2026-05-21T15:40:00Z'),
            
        
    
        
        
            
                "duration_minutes": 150,
            
        
    
        
        
            
                "notes": "Hydraulic leak identified",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "maintenance",
            
        
    
        
        
            
                "reason_code": "unplanned_maintenance",
            
        
    
        
        
            
                "started_at": new Date('2026-05-22T08:00:00Z'),
            
        
    
        
        
            
                "ended_at": new Date('2026-05-22T10:00:00Z'),
            
        
    
        
        
            
                "duration_minutes": 120,
            
        
    
        
        
            
                "notes": "Quarterly PM and temperature calibration",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const UomsData = [
    
    {
    
        
        
            
                "name": "Each",
            
        
    
        
        
            
                "code": "EA",
            
        
    
        
        
            
                "uom_type": "time",
            
        
    
        
        
            
                "base_multiplier": 1,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Kilogram",
            
        
    
        
        
            
                "code": "KG",
            
        
    
        
        
            
                "uom_type": "time",
            
        
    
        
        
            
                "base_multiplier": 1,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Gram",
            
        
    
        
        
            
                "code": "G",
            
        
    
        
        
            
                "uom_type": "count",
            
        
    
        
        
            
                "base_multiplier": 0.001,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const ItemsData = [
    
    {
    
        
        
            
                "name": "Bracket Assembly",
            
        
    
        
        
            
                "item_number": "FG-1000",
            
        
    
        
        
            
                "item_type": "component",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_tracked": true,
            
        
    
        
        
            
                "serial_tracked": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "standard_cost": 24.75,
            
        
    
        
        
            
                "description": "Finished bracket assembly for industrial enclosure",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Steel Plate 3mm",
            
        
    
        
        
            
                "item_number": "RM-2001",
            
        
    
        
        
            
                "item_type": "consumable",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_tracked": true,
            
        
    
        
        
            
                "serial_tracked": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "standard_cost": 1.45,
            
        
    
        
        
            
                "description": "Cold rolled steel plate, 3mm thickness",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Hex Bolt M8x20",
            
        
    
        
        
            
                "item_number": "CMP-3100",
            
        
    
        
        
            
                "item_type": "packaging",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_tracked": false,
            
        
    
        
        
            
                "serial_tracked": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "standard_cost": 0.08,
            
        
    
        
        
            
                "description": "Zinc plated hex bolt, M8x20",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const WarehousesData = [
    
    {
    
        
        
            
                "name": "NP Main Warehouse",
            
        
    
        
        
            
                "code": "NP-WH1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "address": "100 Industrial Way, Dayton, OH",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "SP Raw Materials",
            
        
    
        
        
            
                "code": "SP-WH1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "address": "450 Foundry Rd, Chattanooga, TN",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "CP QA Hold",
            
        
    
        
        
            
                "code": "CP-WH2",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "address": "8 Logistics Park, Columbus, OH",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const LocationsData = [
    
    {
    
        
        
            
                "name": "NP Receiving Dock",
            
        
    
        
        
            
                "code": "NP-REC-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "staging",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "NP Rack A1",
            
        
    
        
        
            
                "code": "NP-STO-A1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "staging",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "SP Staging",
            
        
    
        
        
            
                "code": "SP-STG-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "storage",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                "name": "Midwest Steel Supply",
            
        
    
        
        
            
                "supplier_code": "SUP-STEEL-01",
            
        
    
        
        
            
                "contact_name": "Avery Collins",
            
        
    
        
        
            
                "email": "orders@midweststeelsupply.com",
            
        
    
        
        
            
                "phone": "5550201",
            
        
    
        
        
            
                "address": "12 Mill Park, Toledo, OH",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "notes": "Provides coil and sheet steel",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Precision Fasteners Co",
            
        
    
        
        
            
                "supplier_code": "SUP-FAST-02",
            
        
    
        
        
            
                "contact_name": "Rina Shah",
            
        
    
        
        
            
                "email": "sales@precisionfastenersco.com",
            
        
    
        
        
            
                "phone": "5550202",
            
        
    
        
        
            
                "address": "88 Anchor St, Newark, NJ",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "notes": "Standard and custom fasteners",
            
        
    
    },
    
    {
    
        
        
            
                "name": "ChemCo Powders",
            
        
    
        
        
            
                "supplier_code": "SUP-PWD-03",
            
        
    
        
        
            
                "contact_name": "Tom Reyes",
            
        
    
        
        
            
                "email": "support@chemco-powders.com",
            
        
    
        
        
            
                "phone": "5550203",
            
        
    
        
        
            
                "address": "5 Coating Ave, Atlanta, GA",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "notes": "Powder coat materials with CoC",
            
        
    
    },
    
];



const CustomersData = [
    
    {
    
        
        
            
                "name": "Apex Industrial Systems",
            
        
    
        
        
            
                "customer_code": "CUST-APEX-01",
            
        
    
        
        
            
                "contact_name": "Hannah Kim",
            
        
    
        
        
            
                "email": "hkim@apexindustrial.com",
            
        
    
        
        
            
                "phone": "5550301",
            
        
    
        
        
            
                "address": "900 Market St, Chicago, IL",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "notes": "Monthly blanket orders",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Vector Automation",
            
        
    
        
        
            
                "customer_code": "CUST-VECT-02",
            
        
    
        
        
            
                "contact_name": "Noah Bennett",
            
        
    
        
        
            
                "email": "nbennett@vectorauto.com",
            
        
    
        
        
            
                "phone": "5550302",
            
        
    
        
        
            
                "address": "61 Robotics Way, San Jose, CA",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "notes": "Requires serialized shipments",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Summit HVAC Components",
            
        
    
        
        
            
                "customer_code": "CUST-SUMM-03",
            
        
    
        
        
            
                "contact_name": "Grace Liu",
            
        
    
        
        
            
                "email": "grace.liu@summithvac.com",
            
        
    
        
        
            
                "phone": "5550303",
            
        
    
        
        
            
                "address": "14 Cooling Rd, Denver, CO",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "notes": "Seasonal demand spikes",
            
        
    
    },
    
];



const BomsData = [
    
    {
    
        
        
            
                "name": "BOM Bracket Assembly Rev A",
            
        
    
        
        
            
                "bom_code": "BOM-FG-1000-A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "draft",
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-01-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Initial released BOM",
            
        
    
    },
    
    {
    
        
        
            
                "name": "BOM Bracket Assembly Rev B",
            
        
    
        
        
            
                "bom_code": "BOM-FG-1000-B",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "obsolete",
            
        
    
        
        
            
                "revision": "B",
            
        
    
        
        
            
                "effective_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-06-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Adds additional fastener",
            
        
    
    },
    
    {
    
        
        
            
                "name": "BOM Packaging Kit",
            
        
    
        
        
            
                "bom_code": "BOM-PKG-KIT-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "released",
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "effective_from": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-02-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Packaging materials kit",
            
        
    
    },
    
];



const BomLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 1.8,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scrap_factor_percent": 2.5,
            
        
    
        
        
            
                "line_number": 10,
            
        
    
        
        
            
                "reference_designator": "PLATE",
            
        
    
        
        
            
                "notes": "Cut and machine to profile",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 4,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scrap_factor_percent": 0,
            
        
    
        
        
            
                "line_number": 20,
            
        
    
        
        
            
                "reference_designator": "BOLT",
            
        
    
        
        
            
                "notes": "Fasteners for assembly",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 0.05,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scrap_factor_percent": 5,
            
        
    
        
        
            
                "line_number": 30,
            
        
    
        
        
            
                "reference_designator": "COAT",
            
        
    
        
        
            
                "notes": "Average usage per unit",
            
        
    
    },
    
];



const RoutingsData = [
    
    {
    
        
        
            
                "name": "Routing FG-1000 Rev A",
            
        
    
        
        
            
                "routing_code": "RT-FG-1000-A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "released",
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-01-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Standard routing for FG-1000",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Routing FG-1000 Rev B",
            
        
    
        
        
            
                "routing_code": "RT-FG-1000-B",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "released",
            
        
    
        
        
            
                "revision": "B",
            
        
    
        
        
            
                "effective_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-06-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Updated assembly step",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Routing Coating Only",
            
        
    
        
        
            
                "routing_code": "RT-COAT-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision_status": "obsolete",
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "effective_from": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-03-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Coating operation for rework",
            
        
    
    },
    
];



const RoutingOperationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_number": 10,
            
        
    
        
        
            
                "name": "CNC Machine",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 30,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 1.2,
            
        
    
        
        
            
                "move_time_minutes": 2,
            
        
    
        
        
            
                "queue_time_minutes": 15,
            
        
    
        
        
            
                "instructions": "Machine plate to profile per drawing FG-1000-01",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_number": 20,
            
        
    
        
        
            
                "name": "Assembly",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 10,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 0.8,
            
        
    
        
        
            
                "move_time_minutes": 1,
            
        
    
        
        
            
                "queue_time_minutes": 10,
            
        
    
        
        
            
                "instructions": "Assemble with fasteners to torque spec",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_number": 30,
            
        
    
        
        
            
                "name": "Powder Coat",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 20,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 3.5,
            
        
    
        
        
            
                "move_time_minutes": 5,
            
        
    
        
        
            
                "queue_time_minutes": 30,
            
        
    
        
        
            
                "instructions": "Apply black powder coat and cure per SOP",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const ProductionOrdersData = [
    
    {
    
        
        
            
                "order_number": "PO-10045",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "planned_quantity": 500,
            
        
    
        
        
            
                "completed_quantity": 320,
            
        
    
        
        
            
                "scrapped_quantity": 6,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-05-20T06:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-05-24T18:00:00Z'),
            
        
    
        
        
            
                "released_at": new Date('2026-05-19T15:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-05-25T16:00:00Z'),
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Customer due date end of month",
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "PO-10046",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "planned_quantity": 300,
            
        
    
        
        
            
                "completed_quantity": 0,
            
        
    
        
        
            
                "scrapped_quantity": 0,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-05-27T06:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-05-29T18:00:00Z'),
            
        
    
        
        
            
                "released_at": new Date('2026-05-26T14:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-01T16:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "priority": "high",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Run after material receipt",
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "PO-10047",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "planned_quantity": 120,
            
        
    
        
        
            
                "completed_quantity": 60,
            
        
    
        
        
            
                "scrapped_quantity": 2,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-05-22T07:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-05-23T17:00:00Z'),
            
        
    
        
        
            
                "released_at": new Date('2026-05-21T17:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-05-24T12:00:00Z'),
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "priority": "urgent",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Recoat batch due to finish issue",
            
        
    
    },
    
];



const ProductionOperationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "paused",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-20T06:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-21T12:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-05-20T06:15:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-05-21T11:50:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "good_quantity": 340,
            
        
    
        
        
            
                "scrap_quantity": 4,
            
        
    
        
        
            
                "operator_notes": "Tool wear monitored; adjusted offsets",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-21T13:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-22T12:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-05-21T13:20:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-05-22T11:40:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "good_quantity": 0,
            
        
    
        
        
            
                "scrap_quantity": 0,
            
        
    
        
        
            
                "operator_notes": "Waiting on press repair clearance",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "ready",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-22T07:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-23T17:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-05-22T07:10:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-05-23T16:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "good_quantity": 58,
            
        
    
        
        
            
                "scrap_quantity": 2,
            
        
    
        
        
            
                "operator_notes": "Adjusted cure time after temp check",
            
        
    
    },
    
];



const MaterialRequirementsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_quantity": 900,
            
        
    
        
        
            
                "issued_quantity": 720,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "status": "partially_issued",
            
        
    
        
        
            
                "notes": "Issued from NP Rack A1",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_quantity": 2000,
            
        
    
        
        
            
                "issued_quantity": 1600,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "manual",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "notes": "Backflush at assembly completion",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_quantity": 25,
            
        
    
        
        
            
                "issued_quantity": 20,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "status": "short",
            
        
    
        
        
            
                "notes": "Issued to paint booth",
            
        
    
    },
    
];



const LotsData = [
    
    {
    
        
        
            
                "lot_number": "LOT-RM2001-260520-A",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "manufactured_at": new Date('2026-05-10T00:00:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-05-18T14:20:00Z'),
            
        
    
        
        
            
                "expiration_at": new Date('2028-05-18T00:00:00Z'),
            
        
    
        
        
            
                "quality_status": "quarantine",
            
        
    
        
        
            
                "quantity_on_hand": 1200,
            
        
    
        
        
            
                "notes": "CoC received and filed",
            
        
    
    },
    
    {
    
        
        
            
                "lot_number": "LOT-RM2400-260515-B",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "manufactured_at": new Date('2026-04-28T00:00:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-05-15T10:05:00Z'),
            
        
    
        
        
            
                "expiration_at": new Date('2027-05-15T00:00:00Z'),
            
        
    
        
        
            
                "quality_status": "released",
            
        
    
        
        
            
                "quantity_on_hand": 80,
            
        
    
        
        
            
                "notes": "Pending incoming inspection",
            
        
    
    },
    
    {
    
        
        
            
                "lot_number": "LOT-FG1000-260521-01",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "manufactured_at": new Date('2026-05-21T00:00:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-05-21T00:00:00Z'),
            
        
    
        
        
            
                "expiration_at": new Date('2029-05-21T00:00:00Z'),
            
        
    
        
        
            
                "quality_status": "quarantine",
            
        
    
        
        
            
                "quantity_on_hand": 320,
            
        
    
        
        
            
                "notes": "WIP moved to finished goods staging",
            
        
    
    },
    
];



const SerialNumbersData = [
    
    {
    
        
        
            
                "serial_number": "SN-FG1000-260521-0001",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "in_process",
            
        
    
        
        
            
                "created_on": new Date('2026-05-21T12:00:00Z'),
            
        
    
        
        
            
                "notes": "Reserved for Vector Automation",
            
        
    
    },
    
    {
    
        
        
            
                "serial_number": "SN-FG1000-260521-0002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "in_stock",
            
        
    
        
        
            
                "created_on": new Date('2026-05-21T12:01:00Z'),
            
        
    
        
        
            
                "notes": "Awaiting final packaging",
            
        
    
    },
    
    {
    
        
        
            
                "serial_number": "SN-FG1000-260521-0003",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "scrapped",
            
        
    
        
        
            
                "created_on": new Date('2026-05-21T12:02:00Z'),
            
        
    
        
        
            
                "notes": "Shipped to Apex Industrial Systems",
            
        
    
    },
    
];



const InventoryTransactionsData = [
    
    {
    
        
        
            
                "transaction_number": "ITX-90001",
            
        
    
        
        
            
                "transaction_type": "transfer",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 1200,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "transaction_at": new Date('2026-05-18T14:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reference": "PO Receipt 44521",
            
        
    
        
        
            
                "notes": "Received steel plate into storage",
            
        
    
    },
    
    {
    
        
        
            
                "transaction_number": "ITX-90002",
            
        
    
        
        
            
                "transaction_type": "transfer",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 720,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "transaction_at": new Date('2026-05-20T06:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reference": "Material Issue CNC",
            
        
    
        
        
            
                "notes": "Issued steel to CNC staging",
            
        
    
    },
    
    {
    
        
        
            
                "transaction_number": "ITX-90003",
            
        
    
        
        
            
                "transaction_type": "adjustment",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 200,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "transaction_at": new Date('2026-05-19T15:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reference": "Transfer to shipping",
            
        
    
        
        
            
                "notes": "Moved packed units to shipping lane",
            
        
    
    },
    
];



const InspectionsData = [
    
    {
    
        
        
            
                "inspection_number": "INSP-50001",
            
        
    
        
        
            
                "inspection_type": "final",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scheduled_at": new Date('2026-05-18T16:00:00Z'),
            
        
    
        
        
            
                "performed_at": new Date('2026-05-18T16:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "result": "fail",
            
        
    
        
        
            
                "notes": "Thickness and cert verified",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "INSP-50002",
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scheduled_at": new Date('2026-05-15T14:00:00Z'),
            
        
    
        
        
            
                "performed_at": new Date('2026-05-15T15:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "result": "pending",
            
        
    
        
        
            
                "notes": "Hold pending lab test",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "INSP-50003",
            
        
    
        
        
            
                "inspection_type": "audit",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "scheduled_at": new Date('2026-05-21T10:00:00Z'),
            
        
    
        
        
            
                "performed_at": new Date('2026-05-21T10:25:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "result": "fail",
            
        
    
        
        
            
                "notes": "Critical hole spacing within tolerance",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const InspectionResultsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "characteristic": "Thickness",
            
        
    
        
        
            
                "specification": "3.0 mm plus minus 0.1",
            
        
    
        
        
            
                "measured_value": 3.02,
            
        
    
        
        
            
                "unit_type": "attribute",
            
        
    
        
        
            
                "judgement": "na",
            
        
    
        
        
            
                "notes": "Measured with calibrated micrometer",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "characteristic": "Surface condition",
            
        
    
        
        
            
                "specification": "No rust, no pitting",
            
        
    
        
        
            
                "measured_value": 0,
            
        
    
        
        
            
                "unit_type": "attribute",
            
        
    
        
        
            
                "judgement": "pass",
            
        
    
        
        
            
                "notes": "Visual inspection acceptable",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "characteristic": "Hole spacing",
            
        
    
        
        
            
                "specification": "50.00 mm plus minus 0.10",
            
        
    
        
        
            
                "measured_value": 49.96,
            
        
    
        
        
            
                "unit_type": "attribute",
            
        
    
        
        
            
                "judgement": "fail",
            
        
    
        
        
            
                "notes": "CMM measurement",
            
        
    
    },
    
];



const NonconformancesData = [
    
    {
    
        
        
            
                "ncr_number": "NCR-0007",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "disposition": "sort",
            
        
    
        
        
            
                "reported_at": new Date('2026-05-22T14:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Coating adhesion failure on sample; suspect cure temperature drift",
            
        
    
        
        
            
                "root_cause": "Oven temperature sensor calibration out of tolerance",
            
        
    
        
        
            
                "corrective_action": "Recalibrate oven and recoat affected units",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "NCR-0008",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "disposition": "return_to_supplier",
            
        
    
        
        
            
                "reported_at": new Date('2026-05-15T15:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Incoming lot pending lab test due to color variance concern",
            
        
    
        
        
            
                "root_cause": "Supplier batch pigmentation variation",
            
        
    
        
        
            
                "corrective_action": "Request supplier CoA and run drawdown test",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "NCR-0009",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "contained",
            
        
    
        
        
            
                "disposition": "use_as_is",
            
        
    
        
        
            
                "reported_at": new Date('2026-05-18T16:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Minor edge burrs on some sheets",
            
        
    
        
        
            
                "root_cause": "Handling at supplier shipping",
            
        
    
        
        
            
                "corrective_action": "Deburr prior to CNC; notify supplier",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const QualityHoldsData = [
    
    {
    
        
        
            
                "hold_number": "QH-20001",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "status": "released",
            
        
    
        
        
            
                "hold_started_at": new Date('2026-05-15T15:30:00Z'),
            
        
    
        
        
            
                "hold_released_at": new Date('2026-05-16T15:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Quarantine pending lab test",
            
        
    
    },
    
    {
    
        
        
            
                "hold_number": "QH-20002",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "hold_started_at": new Date('2026-05-22T14:30:00Z'),
            
        
    
        
        
            
                "hold_released_at": new Date('2026-05-23T12:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Hold affected units for adhesion recheck",
            
        
    
    },
    
    {
    
        
        
            
                "hold_number": "QH-20003",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "status": "expired",
            
        
    
        
        
            
                "hold_started_at": new Date('2026-05-18T14:35:00Z'),
            
        
    
        
        
            
                "hold_released_at": new Date('2026-05-18T16:25:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Incoming inspection required",
            
        
    
    },
    
];



const MaintenanceWorkOrdersData = [
    
    {
    
        
        
            
                "work_order_number": "MWO-30001",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "work_type": "calibration",
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "status": "waiting_parts",
            
        
    
        
        
            
                "requested_at": new Date('2026-05-21T13:15:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-21T13:30:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-21T17:30:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-05-21T17:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_description": "Hydraulic leak causing pressure drop",
            
        
    
        
        
            
                "resolution_notes": "Replaced hose and refilled fluid; tested under load",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "MWO-30002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "work_type": "calibration",
            
        
    
        
        
            
                "priority": "normal",
            
        
    
        
        
            
                "status": "scheduled",
            
        
    
        
        
            
                "requested_at": new Date('2026-05-22T07:30:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-22T08:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-22T10:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-05-22T10:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_description": "Verify temperature sensor calibration",
            
        
    
        
        
            
                "resolution_notes": "Calibrated sensor and logged results",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "MWO-30003",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "work_type": "inspection",
            
        
    
        
        
            
                "priority": "urgent",
            
        
    
        
        
            
                "status": "waiting_parts",
            
        
    
        
        
            
                "requested_at": new Date('2026-05-25T08:00:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-05-26T08:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-05-26T11:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-05-26T11:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_description": "Monthly PM check",
            
        
    
        
        
            
                "resolution_notes": "Lubrication and axis check complete",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const DocumentsData = [
    
    {
    
        
        
            
                "title": "FG-1000 Drawing",
            
        
    
        
        
            
                "document_type": "form",
            
        
    
        
        
            
                "document_number": "DOC-FG1000-DRW",
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-01-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Primary engineering drawing for bracket assembly",
            
        
    
    },
    
    {
    
        
        
            
                "title": "SOP Powder Coat Cure",
            
        
    
        
        
            
                "document_type": "form",
            
        
    
        
        
            
                "document_number": "DOC-SOP-COAT-01",
            
        
    
        
        
            
                "revision": "C",
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "effective_from": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-03-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Cure profile and adhesion checks for coating",
            
        
    
    },
    
    {
    
        
        
            
                "title": "Receiving Inspection Checklist",
            
        
    
        
        
            
                "document_type": "form",
            
        
    
        
        
            
                "document_number": "DOC-QA-REC-CHK",
            
        
    
        
        
            
                "revision": "B",
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "effective_from": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-02-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Checklist for incoming material inspection",
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateWorkCenterWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter0 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkCenter0?.setPlant)
                {
                    await
                    WorkCenter0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter1 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkCenter1?.setPlant)
                {
                    await
                    WorkCenter1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter2 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkCenter2?.setPlant)
                {
                    await
                    WorkCenter2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateMachineWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine0 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Machine0?.setWork_center)
                {
                    await
                    Machine0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine1 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Machine1?.setWork_center)
                {
                    await
                    Machine1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine2 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Machine2?.setWork_center)
                {
                    await
                    Machine2.
                    setWork_center(relatedWork_center2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateMachineEventWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MachineEvent0 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MachineEvent0?.setMachine)
                {
                    await
                    MachineEvent0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MachineEvent1 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MachineEvent1?.setMachine)
                {
                    await
                    MachineEvent1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MachineEvent2 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MachineEvent2?.setMachine)
                {
                    await
                    MachineEvent2.
                    setMachine(relatedMachine2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMachineEventWithReported_by() {
            
                const relatedReported_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MachineEvent0 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MachineEvent0?.setReported_by)
                {
                    await
                    MachineEvent0.
                    setReported_by(relatedReported_by0);
                }
            
                const relatedReported_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MachineEvent1 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MachineEvent1?.setReported_by)
                {
                    await
                    MachineEvent1.
                    setReported_by(relatedReported_by1);
                }
            
                const relatedReported_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MachineEvent2 = await MachineEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MachineEvent2?.setReported_by)
                {
                    await
                    MachineEvent2.
                    setReported_by(relatedReported_by2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateItemWithDefault_uom() {
            
                const relatedDefault_uom0 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item0 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Item0?.setDefault_uom)
                {
                    await
                    Item0.
                    setDefault_uom(relatedDefault_uom0);
                }
            
                const relatedDefault_uom1 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item1 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Item1?.setDefault_uom)
                {
                    await
                    Item1.
                    setDefault_uom(relatedDefault_uom1);
                }
            
                const relatedDefault_uom2 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item2 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Item2?.setDefault_uom)
                {
                    await
                    Item2.
                    setDefault_uom(relatedDefault_uom2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateItemWithDefault_warehouse() {
            
                const relatedDefault_warehouse0 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Item0 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Item0?.setDefault_warehouse)
                {
                    await
                    Item0.
                    setDefault_warehouse(relatedDefault_warehouse0);
                }
            
                const relatedDefault_warehouse1 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Item1 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Item1?.setDefault_warehouse)
                {
                    await
                    Item1.
                    setDefault_warehouse(relatedDefault_warehouse1);
                }
            
                const relatedDefault_warehouse2 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Item2 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Item2?.setDefault_warehouse)
                {
                    await
                    Item2.
                    setDefault_warehouse(relatedDefault_warehouse2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateWarehousWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous0 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Warehous0?.setPlant)
                {
                    await
                    Warehous0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous1 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Warehous1?.setPlant)
                {
                    await
                    Warehous1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous2 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Warehous2?.setPlant)
                {
                    await
                    Warehous2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateLocationWithWarehouse() {
            
                const relatedWarehouse0 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location0 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Location0?.setWarehouse)
                {
                    await
                    Location0.
                    setWarehouse(relatedWarehouse0);
                }
            
                const relatedWarehouse1 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location1 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Location1?.setWarehouse)
                {
                    await
                    Location1.
                    setWarehouse(relatedWarehouse1);
                }
            
                const relatedWarehouse2 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location2 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Location2?.setWarehouse)
                {
                    await
                    Location2.
                    setWarehouse(relatedWarehouse2);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateBomWithParent_item() {
            
                const relatedParent_item0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom0 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Bom0?.setParent_item)
                {
                    await
                    Bom0.
                    setParent_item(relatedParent_item0);
                }
            
                const relatedParent_item1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom1 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Bom1?.setParent_item)
                {
                    await
                    Bom1.
                    setParent_item(relatedParent_item1);
                }
            
                const relatedParent_item2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom2 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Bom2?.setParent_item)
                {
                    await
                    Bom2.
                    setParent_item(relatedParent_item2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateBomLineWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine0 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomLine0?.setBom)
                {
                    await
                    BomLine0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine1 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomLine1?.setBom)
                {
                    await
                    BomLine1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine2 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomLine2?.setBom)
                {
                    await
                    BomLine2.
                    setBom(relatedBom2);
                }
            
        }
        
    
        
            
            async function associateBomLineWithComponent_item() {
            
                const relatedComponent_item0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine0 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomLine0?.setComponent_item)
                {
                    await
                    BomLine0.
                    setComponent_item(relatedComponent_item0);
                }
            
                const relatedComponent_item1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine1 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomLine1?.setComponent_item)
                {
                    await
                    BomLine1.
                    setComponent_item(relatedComponent_item1);
                }
            
                const relatedComponent_item2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine2 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomLine2?.setComponent_item)
                {
                    await
                    BomLine2.
                    setComponent_item(relatedComponent_item2);
                }
            
        }
        
    
        
    
        
            
            async function associateBomLineWithUom() {
            
                const relatedUom0 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const BomLine0 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomLine0?.setUom)
                {
                    await
                    BomLine0.
                    setUom(relatedUom0);
                }
            
                const relatedUom1 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const BomLine1 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomLine1?.setUom)
                {
                    await
                    BomLine1.
                    setUom(relatedUom1);
                }
            
                const relatedUom2 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const BomLine2 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomLine2?.setUom)
                {
                    await
                    BomLine2.
                    setUom(relatedUom2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateRoutingWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing0 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Routing0?.setItem)
                {
                    await
                    Routing0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing1 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Routing1?.setItem)
                {
                    await
                    Routing1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing2 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Routing2?.setItem)
                {
                    await
                    Routing2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateRoutingOperationWithRouting() {
            
                const relatedRouting0 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation0 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RoutingOperation0?.setRouting)
                {
                    await
                    RoutingOperation0.
                    setRouting(relatedRouting0);
                }
            
                const relatedRouting1 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation1 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RoutingOperation1?.setRouting)
                {
                    await
                    RoutingOperation1.
                    setRouting(relatedRouting1);
                }
            
                const relatedRouting2 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation2 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RoutingOperation2?.setRouting)
                {
                    await
                    RoutingOperation2.
                    setRouting(relatedRouting2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateRoutingOperationWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation0 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RoutingOperation0?.setWork_center)
                {
                    await
                    RoutingOperation0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation1 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RoutingOperation1?.setWork_center)
                {
                    await
                    RoutingOperation1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation2 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RoutingOperation2?.setWork_center)
                {
                    await
                    RoutingOperation2.
                    setWork_center(relatedWork_center2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateProductionOrderWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setPlant)
                {
                    await
                    ProductionOrder0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setPlant)
                {
                    await
                    ProductionOrder1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setPlant)
                {
                    await
                    ProductionOrder2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setItem)
                {
                    await
                    ProductionOrder0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setItem)
                {
                    await
                    ProductionOrder1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setItem)
                {
                    await
                    ProductionOrder2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setBom)
                {
                    await
                    ProductionOrder0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setBom)
                {
                    await
                    ProductionOrder1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setBom)
                {
                    await
                    ProductionOrder2.
                    setBom(relatedBom2);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithRouting() {
            
                const relatedRouting0 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setRouting)
                {
                    await
                    ProductionOrder0.
                    setRouting(relatedRouting0);
                }
            
                const relatedRouting1 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setRouting)
                {
                    await
                    ProductionOrder1.
                    setRouting(relatedRouting1);
                }
            
                const relatedRouting2 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setRouting)
                {
                    await
                    ProductionOrder2.
                    setRouting(relatedRouting2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductionOrderWithPlanner() {
            
                const relatedPlanner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setPlanner)
                {
                    await
                    ProductionOrder0.
                    setPlanner(relatedPlanner0);
                }
            
                const relatedPlanner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setPlanner)
                {
                    await
                    ProductionOrder1.
                    setPlanner(relatedPlanner1);
                }
            
                const relatedPlanner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setPlanner)
                {
                    await
                    ProductionOrder2.
                    setPlanner(relatedPlanner2);
                }
            
        }
        
    
        
    

    
    
    
        
            
            async function associateProductionOperationWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setProduction_order)
                {
                    await
                    ProductionOperation0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setProduction_order)
                {
                    await
                    ProductionOperation1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setProduction_order)
                {
                    await
                    ProductionOperation2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
            
            async function associateProductionOperationWithRouting_operation() {
            
                const relatedRouting_operation0 = await RoutingOperations.findOne({
                    offset: Math.floor(Math.random() * (await RoutingOperations.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setRouting_operation)
                {
                    await
                    ProductionOperation0.
                    setRouting_operation(relatedRouting_operation0);
                }
            
                const relatedRouting_operation1 = await RoutingOperations.findOne({
                    offset: Math.floor(Math.random() * (await RoutingOperations.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setRouting_operation)
                {
                    await
                    ProductionOperation1.
                    setRouting_operation(relatedRouting_operation1);
                }
            
                const relatedRouting_operation2 = await RoutingOperations.findOne({
                    offset: Math.floor(Math.random() * (await RoutingOperations.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setRouting_operation)
                {
                    await
                    ProductionOperation2.
                    setRouting_operation(relatedRouting_operation2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductionOperationWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setMachine)
                {
                    await
                    ProductionOperation0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setMachine)
                {
                    await
                    ProductionOperation1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setMachine)
                {
                    await
                    ProductionOperation2.
                    setMachine(relatedMachine2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateMaterialRequirementWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const MaterialRequirement0 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaterialRequirement0?.setProduction_order)
                {
                    await
                    MaterialRequirement0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const MaterialRequirement1 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaterialRequirement1?.setProduction_order)
                {
                    await
                    MaterialRequirement1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const MaterialRequirement2 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaterialRequirement2?.setProduction_order)
                {
                    await
                    MaterialRequirement2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
            
            async function associateMaterialRequirementWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const MaterialRequirement0 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaterialRequirement0?.setItem)
                {
                    await
                    MaterialRequirement0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const MaterialRequirement1 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaterialRequirement1?.setItem)
                {
                    await
                    MaterialRequirement1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const MaterialRequirement2 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaterialRequirement2?.setItem)
                {
                    await
                    MaterialRequirement2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateMaterialRequirementWithUom() {
            
                const relatedUom0 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const MaterialRequirement0 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaterialRequirement0?.setUom)
                {
                    await
                    MaterialRequirement0.
                    setUom(relatedUom0);
                }
            
                const relatedUom1 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const MaterialRequirement1 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaterialRequirement1?.setUom)
                {
                    await
                    MaterialRequirement1.
                    setUom(relatedUom1);
                }
            
                const relatedUom2 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const MaterialRequirement2 = await MaterialRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaterialRequirement2?.setUom)
                {
                    await
                    MaterialRequirement2.
                    setUom(relatedUom2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateLotWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Lot0 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lot0?.setItem)
                {
                    await
                    Lot0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Lot1 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lot1?.setItem)
                {
                    await
                    Lot1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Lot2 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lot2?.setItem)
                {
                    await
                    Lot2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateLotWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Lot0 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lot0?.setPlant)
                {
                    await
                    Lot0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Lot1 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lot1?.setPlant)
                {
                    await
                    Lot1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Lot2 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lot2?.setPlant)
                {
                    await
                    Lot2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
            
            async function associateLotWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Lot0 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lot0?.setSupplier)
                {
                    await
                    Lot0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Lot1 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lot1?.setSupplier)
                {
                    await
                    Lot1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Lot2 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lot2?.setSupplier)
                {
                    await
                    Lot2.
                    setSupplier(relatedSupplier2);
                }
            
        }
        
    
        
            
            async function associateLotWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Lot0 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lot0?.setProduction_order)
                {
                    await
                    Lot0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Lot1 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lot1?.setProduction_order)
                {
                    await
                    Lot1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Lot2 = await Lots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lot2?.setProduction_order)
                {
                    await
                    Lot2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateSerialNumberWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const SerialNumber0 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SerialNumber0?.setItem)
                {
                    await
                    SerialNumber0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const SerialNumber1 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SerialNumber1?.setItem)
                {
                    await
                    SerialNumber1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const SerialNumber2 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SerialNumber2?.setItem)
                {
                    await
                    SerialNumber2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateSerialNumberWithLot() {
            
                const relatedLot0 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const SerialNumber0 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SerialNumber0?.setLot)
                {
                    await
                    SerialNumber0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const SerialNumber1 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SerialNumber1?.setLot)
                {
                    await
                    SerialNumber1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const SerialNumber2 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SerialNumber2?.setLot)
                {
                    await
                    SerialNumber2.
                    setLot(relatedLot2);
                }
            
        }
        
    
        
            
            async function associateSerialNumberWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const SerialNumber0 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SerialNumber0?.setProduction_order)
                {
                    await
                    SerialNumber0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const SerialNumber1 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SerialNumber1?.setProduction_order)
                {
                    await
                    SerialNumber1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const SerialNumber2 = await SerialNumbers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SerialNumber2?.setProduction_order)
                {
                    await
                    SerialNumber2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateInventoryTransactionWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setItem)
                {
                    await
                    InventoryTransaction0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setItem)
                {
                    await
                    InventoryTransaction1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setItem)
                {
                    await
                    InventoryTransaction2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithLot() {
            
                const relatedLot0 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setLot)
                {
                    await
                    InventoryTransaction0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setLot)
                {
                    await
                    InventoryTransaction1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setLot)
                {
                    await
                    InventoryTransaction2.
                    setLot(relatedLot2);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithSerial_number() {
            
                const relatedSerial_number0 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setSerial_number)
                {
                    await
                    InventoryTransaction0.
                    setSerial_number(relatedSerial_number0);
                }
            
                const relatedSerial_number1 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setSerial_number)
                {
                    await
                    InventoryTransaction1.
                    setSerial_number(relatedSerial_number1);
                }
            
                const relatedSerial_number2 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setSerial_number)
                {
                    await
                    InventoryTransaction2.
                    setSerial_number(relatedSerial_number2);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithFrom_location() {
            
                const relatedFrom_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setFrom_location)
                {
                    await
                    InventoryTransaction0.
                    setFrom_location(relatedFrom_location0);
                }
            
                const relatedFrom_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setFrom_location)
                {
                    await
                    InventoryTransaction1.
                    setFrom_location(relatedFrom_location1);
                }
            
                const relatedFrom_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setFrom_location)
                {
                    await
                    InventoryTransaction2.
                    setFrom_location(relatedFrom_location2);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithTo_location() {
            
                const relatedTo_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setTo_location)
                {
                    await
                    InventoryTransaction0.
                    setTo_location(relatedTo_location0);
                }
            
                const relatedTo_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setTo_location)
                {
                    await
                    InventoryTransaction1.
                    setTo_location(relatedTo_location1);
                }
            
                const relatedTo_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setTo_location)
                {
                    await
                    InventoryTransaction2.
                    setTo_location(relatedTo_location2);
                }
            
        }
        
    
        
    
        
            
            async function associateInventoryTransactionWithUom() {
            
                const relatedUom0 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setUom)
                {
                    await
                    InventoryTransaction0.
                    setUom(relatedUom0);
                }
            
                const relatedUom1 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setUom)
                {
                    await
                    InventoryTransaction1.
                    setUom(relatedUom1);
                }
            
                const relatedUom2 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setUom)
                {
                    await
                    InventoryTransaction2.
                    setUom(relatedUom2);
                }
            
        }
        
    
        
    
        
            
            async function associateInventoryTransactionWithReference_production_order() {
            
                const relatedReference_production_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setReference_production_order)
                {
                    await
                    InventoryTransaction0.
                    setReference_production_order(relatedReference_production_order0);
                }
            
                const relatedReference_production_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setReference_production_order)
                {
                    await
                    InventoryTransaction1.
                    setReference_production_order(relatedReference_production_order1);
                }
            
                const relatedReference_production_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setReference_production_order)
                {
                    await
                    InventoryTransaction2.
                    setReference_production_order(relatedReference_production_order2);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithPerformed_by() {
            
                const relatedPerformed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setPerformed_by)
                {
                    await
                    InventoryTransaction0.
                    setPerformed_by(relatedPerformed_by0);
                }
            
                const relatedPerformed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setPerformed_by)
                {
                    await
                    InventoryTransaction1.
                    setPerformed_by(relatedPerformed_by1);
                }
            
                const relatedPerformed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setPerformed_by)
                {
                    await
                    InventoryTransaction2.
                    setPerformed_by(relatedPerformed_by2);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateInspectionWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setPlant)
                {
                    await
                    Inspection0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setPlant)
                {
                    await
                    Inspection1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setPlant)
                {
                    await
                    Inspection2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
            
            async function associateInspectionWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setItem)
                {
                    await
                    Inspection0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setItem)
                {
                    await
                    Inspection1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setItem)
                {
                    await
                    Inspection2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateInspectionWithLot() {
            
                const relatedLot0 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setLot)
                {
                    await
                    Inspection0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setLot)
                {
                    await
                    Inspection1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setLot)
                {
                    await
                    Inspection2.
                    setLot(relatedLot2);
                }
            
        }
        
    
        
            
            async function associateInspectionWithSerial_number() {
            
                const relatedSerial_number0 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setSerial_number)
                {
                    await
                    Inspection0.
                    setSerial_number(relatedSerial_number0);
                }
            
                const relatedSerial_number1 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setSerial_number)
                {
                    await
                    Inspection1.
                    setSerial_number(relatedSerial_number1);
                }
            
                const relatedSerial_number2 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setSerial_number)
                {
                    await
                    Inspection2.
                    setSerial_number(relatedSerial_number2);
                }
            
        }
        
    
        
            
            async function associateInspectionWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setProduction_order)
                {
                    await
                    Inspection0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setProduction_order)
                {
                    await
                    Inspection1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setProduction_order)
                {
                    await
                    Inspection2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateInspectionWithInspector() {
            
                const relatedInspector0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Inspection0 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Inspection0?.setInspector)
                {
                    await
                    Inspection0.
                    setInspector(relatedInspector0);
                }
            
                const relatedInspector1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Inspection1 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Inspection1?.setInspector)
                {
                    await
                    Inspection1.
                    setInspector(relatedInspector1);
                }
            
                const relatedInspector2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Inspection2 = await Inspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Inspection2?.setInspector)
                {
                    await
                    Inspection2.
                    setInspector(relatedInspector2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateInspectionResultWithInspection() {
            
                const relatedInspection0 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const InspectionResult0 = await InspectionResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InspectionResult0?.setInspection)
                {
                    await
                    InspectionResult0.
                    setInspection(relatedInspection0);
                }
            
                const relatedInspection1 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const InspectionResult1 = await InspectionResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InspectionResult1?.setInspection)
                {
                    await
                    InspectionResult1.
                    setInspection(relatedInspection1);
                }
            
                const relatedInspection2 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const InspectionResult2 = await InspectionResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InspectionResult2?.setInspection)
                {
                    await
                    InspectionResult2.
                    setInspection(relatedInspection2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateNonconformanceWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setPlant)
                {
                    await
                    Nonconformance0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setPlant)
                {
                    await
                    Nonconformance1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setPlant)
                {
                    await
                    Nonconformance2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setItem)
                {
                    await
                    Nonconformance0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setItem)
                {
                    await
                    Nonconformance1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setItem)
                {
                    await
                    Nonconformance2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithLot() {
            
                const relatedLot0 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setLot)
                {
                    await
                    Nonconformance0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setLot)
                {
                    await
                    Nonconformance1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setLot)
                {
                    await
                    Nonconformance2.
                    setLot(relatedLot2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithSerial_number() {
            
                const relatedSerial_number0 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setSerial_number)
                {
                    await
                    Nonconformance0.
                    setSerial_number(relatedSerial_number0);
                }
            
                const relatedSerial_number1 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setSerial_number)
                {
                    await
                    Nonconformance1.
                    setSerial_number(relatedSerial_number1);
                }
            
                const relatedSerial_number2 = await SerialNumbers.findOne({
                    offset: Math.floor(Math.random() * (await SerialNumbers.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setSerial_number)
                {
                    await
                    Nonconformance2.
                    setSerial_number(relatedSerial_number2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setProduction_order)
                {
                    await
                    Nonconformance0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setProduction_order)
                {
                    await
                    Nonconformance1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setProduction_order)
                {
                    await
                    Nonconformance2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithInspection() {
            
                const relatedInspection0 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setInspection)
                {
                    await
                    Nonconformance0.
                    setInspection(relatedInspection0);
                }
            
                const relatedInspection1 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setInspection)
                {
                    await
                    Nonconformance1.
                    setInspection(relatedInspection1);
                }
            
                const relatedInspection2 = await Inspections.findOne({
                    offset: Math.floor(Math.random() * (await Inspections.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setInspection)
                {
                    await
                    Nonconformance2.
                    setInspection(relatedInspection2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithReported_by() {
            
                const relatedReported_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setReported_by)
                {
                    await
                    Nonconformance0.
                    setReported_by(relatedReported_by0);
                }
            
                const relatedReported_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setReported_by)
                {
                    await
                    Nonconformance1.
                    setReported_by(relatedReported_by1);
                }
            
                const relatedReported_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setReported_by)
                {
                    await
                    Nonconformance2.
                    setReported_by(relatedReported_by2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateQualityHoldWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setPlant)
                {
                    await
                    QualityHold0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setPlant)
                {
                    await
                    QualityHold1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setPlant)
                {
                    await
                    QualityHold2.
                    setPlant(relatedPlant2);
                }
            
        }
        
    
        
            
            async function associateQualityHoldWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setItem)
                {
                    await
                    QualityHold0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setItem)
                {
                    await
                    QualityHold1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setItem)
                {
                    await
                    QualityHold2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateQualityHoldWithLot() {
            
                const relatedLot0 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setLot)
                {
                    await
                    QualityHold0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setLot)
                {
                    await
                    QualityHold1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await Lots.findOne({
                    offset: Math.floor(Math.random() * (await Lots.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setLot)
                {
                    await
                    QualityHold2.
                    setLot(relatedLot2);
                }
            
        }
        
    
        
            
            async function associateQualityHoldWithLocation() {
            
                const relatedLocation0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setLocation)
                {
                    await
                    QualityHold0.
                    setLocation(relatedLocation0);
                }
            
                const relatedLocation1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setLocation)
                {
                    await
                    QualityHold1.
                    setLocation(relatedLocation1);
                }
            
                const relatedLocation2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setLocation)
                {
                    await
                    QualityHold2.
                    setLocation(relatedLocation2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateQualityHoldWithPlaced_by() {
            
                const relatedPlaced_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setPlaced_by)
                {
                    await
                    QualityHold0.
                    setPlaced_by(relatedPlaced_by0);
                }
            
                const relatedPlaced_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setPlaced_by)
                {
                    await
                    QualityHold1.
                    setPlaced_by(relatedPlaced_by1);
                }
            
                const relatedPlaced_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setPlaced_by)
                {
                    await
                    QualityHold2.
                    setPlaced_by(relatedPlaced_by2);
                }
            
        }
        
    
        
            
            async function associateQualityHoldWithReleased_by() {
            
                const relatedReleased_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold0 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityHold0?.setReleased_by)
                {
                    await
                    QualityHold0.
                    setReleased_by(relatedReleased_by0);
                }
            
                const relatedReleased_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold1 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityHold1?.setReleased_by)
                {
                    await
                    QualityHold1.
                    setReleased_by(relatedReleased_by1);
                }
            
                const relatedReleased_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityHold2 = await QualityHolds.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityHold2?.setReleased_by)
                {
                    await
                    QualityHold2.
                    setReleased_by(relatedReleased_by2);
                }
            
        }
        
    
        
    

    
    
    
        
    
        
            
            async function associateMaintenanceWorkOrderWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setMachine)
                {
                    await
                    MaintenanceWorkOrder0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setMachine)
                {
                    await
                    MaintenanceWorkOrder1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setMachine)
                {
                    await
                    MaintenanceWorkOrder2.
                    setMachine(relatedMachine2);
                }
            
        }
        
    
        
            
            async function associateMaintenanceWorkOrderWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setWork_center)
                {
                    await
                    MaintenanceWorkOrder0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setWork_center)
                {
                    await
                    MaintenanceWorkOrder1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setWork_center)
                {
                    await
                    MaintenanceWorkOrder2.
                    setWork_center(relatedWork_center2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMaintenanceWorkOrderWithRequested_by() {
            
                const relatedRequested_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setRequested_by)
                {
                    await
                    MaintenanceWorkOrder0.
                    setRequested_by(relatedRequested_by0);
                }
            
                const relatedRequested_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setRequested_by)
                {
                    await
                    MaintenanceWorkOrder1.
                    setRequested_by(relatedRequested_by1);
                }
            
                const relatedRequested_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setRequested_by)
                {
                    await
                    MaintenanceWorkOrder2.
                    setRequested_by(relatedRequested_by2);
                }
            
        }
        
    
        
            
            async function associateMaintenanceWorkOrderWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDocumentWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setItem)
                {
                    await
                    Document0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setItem)
                {
                    await
                    Document1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setItem)
                {
                    await
                    Document2.
                    setItem(relatedItem2);
                }
            
        }
        
    
        
            
            async function associateDocumentWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setBom)
                {
                    await
                    Document0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setBom)
                {
                    await
                    Document1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setBom)
                {
                    await
                    Document2.
                    setBom(relatedBom2);
                }
            
        }
        
    
        
            
            async function associateDocumentWithRouting() {
            
                const relatedRouting0 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setRouting)
                {
                    await
                    Document0.
                    setRouting(relatedRouting0);
                }
            
                const relatedRouting1 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setRouting)
                {
                    await
                    Document1.
                    setRouting(relatedRouting1);
                }
            
                const relatedRouting2 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setRouting)
                {
                    await
                    Document2.
                    setRouting(relatedRouting2);
                }
            
        }
        
    
        
            
            async function associateDocumentWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setMachine)
                {
                    await
                    Document0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setMachine)
                {
                    await
                    Document1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setMachine)
                {
                    await
                    Document2.
                    setMachine(relatedMachine2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateDocumentWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setOwner)
                {
                    await
                    Document0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setOwner)
                {
                    await
                    Document1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setOwner)
                {
                    await
                    Document2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Plants.bulkCreate(PlantsData);
                
            
            
                
                await WorkCenters.bulkCreate(WorkCentersData);
                
            
            
                
                await Machines.bulkCreate(MachinesData);
                
            
            
                
                await MachineEvents.bulkCreate(MachineEventsData);
                
            
            
                
                await Uoms.bulkCreate(UomsData);
                
            
            
                
                await Items.bulkCreate(ItemsData);
                
            
            
                
                await Warehouses.bulkCreate(WarehousesData);
                
            
            
                
                await Locations.bulkCreate(LocationsData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await Boms.bulkCreate(BomsData);
                
            
            
                
                await BomLines.bulkCreate(BomLinesData);
                
            
            
                
                await Routings.bulkCreate(RoutingsData);
                
            
            
                
                await RoutingOperations.bulkCreate(RoutingOperationsData);
                
            
            
                
                await ProductionOrders.bulkCreate(ProductionOrdersData);
                
            
            
                
                await ProductionOperations.bulkCreate(ProductionOperationsData);
                
            
            
                
                await MaterialRequirements.bulkCreate(MaterialRequirementsData);
                
            
            
                
                await Lots.bulkCreate(LotsData);
                
            
            
                
                await SerialNumbers.bulkCreate(SerialNumbersData);
                
            
            
                
                await InventoryTransactions.bulkCreate(InventoryTransactionsData);
                
            
            
                
                await Inspections.bulkCreate(InspectionsData);
                
            
            
                
                await InspectionResults.bulkCreate(InspectionResultsData);
                
            
            
                
                await Nonconformances.bulkCreate(NonconformancesData);
                
            
            
                
                await QualityHolds.bulkCreate(QualityHoldsData);
                
            
            
                
                await MaintenanceWorkOrders.bulkCreate(MaintenanceWorkOrdersData);
                
            
            
                
                await Documents.bulkCreate(DocumentsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateWorkCenterWithPlant(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMachineWithWork_center(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateMachineEventWithMachine(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMachineEventWithReported_by(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateItemWithDefault_uom(),
                    
                
                    
                
                    
                
                    
                        
                        await associateItemWithDefault_warehouse(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateWarehousWithPlant(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateLocationWithWarehouse(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateBomWithParent_item(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateBomLineWithBom(),
                    
                
                    
                        
                        await associateBomLineWithComponent_item(),
                    
                
                    
                
                    
                        
                        await associateBomLineWithUom(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateRoutingWithItem(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateRoutingOperationWithRouting(),
                    
                
                    
                
                    
                
                    
                        
                        await associateRoutingOperationWithWork_center(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateProductionOrderWithPlant(),
                    
                
                    
                        
                        await associateProductionOrderWithItem(),
                    
                
                    
                        
                        await associateProductionOrderWithBom(),
                    
                
                    
                        
                        await associateProductionOrderWithRouting(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOrderWithPlanner(),
                    
                
                    
                
            
                
                
                    
                        
                        await associateProductionOperationWithProduction_order(),
                    
                
                    
                        
                        await associateProductionOperationWithRouting_operation(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOperationWithMachine(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateMaterialRequirementWithProduction_order(),
                    
                
                    
                        
                        await associateMaterialRequirementWithItem(),
                    
                
                    
                
                    
                
                    
                        
                        await associateMaterialRequirementWithUom(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateLotWithItem(),
                    
                
                    
                        
                        await associateLotWithPlant(),
                    
                
                    
                        
                        await associateLotWithSupplier(),
                    
                
                    
                        
                        await associateLotWithProduction_order(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateSerialNumberWithItem(),
                    
                
                    
                        
                        await associateSerialNumberWithLot(),
                    
                
                    
                        
                        await associateSerialNumberWithProduction_order(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithItem(),
                    
                
                    
                        
                        await associateInventoryTransactionWithLot(),
                    
                
                    
                        
                        await associateInventoryTransactionWithSerial_number(),
                    
                
                    
                        
                        await associateInventoryTransactionWithFrom_location(),
                    
                
                    
                        
                        await associateInventoryTransactionWithTo_location(),
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithUom(),
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithReference_production_order(),
                    
                
                    
                        
                        await associateInventoryTransactionWithPerformed_by(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateInspectionWithPlant(),
                    
                
                    
                        
                        await associateInspectionWithItem(),
                    
                
                    
                        
                        await associateInspectionWithLot(),
                    
                
                    
                        
                        await associateInspectionWithSerial_number(),
                    
                
                    
                        
                        await associateInspectionWithProduction_order(),
                    
                
                    
                
                    
                
                    
                        
                        await associateInspectionWithInspector(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateInspectionResultWithInspection(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateNonconformanceWithPlant(),
                    
                
                    
                        
                        await associateNonconformanceWithItem(),
                    
                
                    
                        
                        await associateNonconformanceWithLot(),
                    
                
                    
                        
                        await associateNonconformanceWithSerial_number(),
                    
                
                    
                        
                        await associateNonconformanceWithProduction_order(),
                    
                
                    
                        
                        await associateNonconformanceWithInspection(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithReported_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateQualityHoldWithPlant(),
                    
                
                    
                        
                        await associateQualityHoldWithItem(),
                    
                
                    
                        
                        await associateQualityHoldWithLot(),
                    
                
                    
                        
                        await associateQualityHoldWithLocation(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateQualityHoldWithPlaced_by(),
                    
                
                    
                        
                        await associateQualityHoldWithReleased_by(),
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithMachine(),
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithWork_center(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithRequested_by(),
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithAssigned_to(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentWithItem(),
                    
                
                    
                        
                        await associateDocumentWithBom(),
                    
                
                    
                        
                        await associateDocumentWithRouting(),
                    
                
                    
                        
                        await associateDocumentWithMachine(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentWithOwner(),
                    
                
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('plants', null, {});
            
            
            await queryInterface.bulkDelete('work_centers', null, {});
            
            
            await queryInterface.bulkDelete('machines', null, {});
            
            
            await queryInterface.bulkDelete('machine_events', null, {});
            
            
            await queryInterface.bulkDelete('uoms', null, {});
            
            
            await queryInterface.bulkDelete('items', null, {});
            
            
            await queryInterface.bulkDelete('warehouses', null, {});
            
            
            await queryInterface.bulkDelete('locations', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('boms', null, {});
            
            
            await queryInterface.bulkDelete('bom_lines', null, {});
            
            
            await queryInterface.bulkDelete('routings', null, {});
            
            
            await queryInterface.bulkDelete('routing_operations', null, {});
            
            
            await queryInterface.bulkDelete('production_orders', null, {});
            
            
            await queryInterface.bulkDelete('production_operations', null, {});
            
            
            await queryInterface.bulkDelete('material_requirements', null, {});
            
            
            await queryInterface.bulkDelete('lots', null, {});
            
            
            await queryInterface.bulkDelete('serial_numbers', null, {});
            
            
            await queryInterface.bulkDelete('inventory_transactions', null, {});
            
            
            await queryInterface.bulkDelete('inspections', null, {});
            
            
            await queryInterface.bulkDelete('inspection_results', null, {});
            
            
            await queryInterface.bulkDelete('nonconformances', null, {});
            
            
            await queryInterface.bulkDelete('quality_holds', null, {});
            
            
            await queryInterface.bulkDelete('maintenance_work_orders', null, {});
            
            
            await queryInterface.bulkDelete('documents', null, {});
            
        
    },
};