





















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






const Organizations = db.organizations;

const Companies = db.companies;

const Contacts = db.contacts;

const Pipelines = db.pipelines;

const PipelineStages = db.pipeline_stages;

const Leads = db.leads;

const Deals = db.deals;

const Activities = db.activities;

const Materials = db.materials;

const Warehouses = db.warehouses;

const InventoryItems = db.inventory_items;

const Machines = db.machines;

const ProductionOrders = db.production_orders;

const ProductionOperations = db.production_operations;

const QualityInspections = db.quality_inspections;

const Nonconformances = db.nonconformances;

const Vendors = db.vendors;

const Venues = db.venues;

const Events = db.events;

const EventTasks = db.event_tasks;

const EventGuests = db.event_guests;

const EventScheduleItems = db.event_schedule_items;

const BudgetItems = db.budget_items;







const OrganizationsData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
    },
    
];



const CompaniesData = [
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "legal_name": "Ada Lovelace",
            
        
    
        
        
            
                "tax_number": "Marie Curie",
            
        
    
        
        
            
                "industry": "Marie Curie",
            
        
    
        
        
            
                "website": "Alan Turing",
            
        
    
        
        
            
                "phone": "Grace Hopper",
            
        
    
        
        
            
                "email": "Marie Curie",
            
        
    
        
        
            
                "billing_address": "Marie Curie",
            
        
    
        
        
            
                "shipping_address": "Marie Curie",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "legal_name": "Grace Hopper",
            
        
    
        
        
            
                "tax_number": "Grace Hopper",
            
        
    
        
        
            
                "industry": "Marie Curie",
            
        
    
        
        
            
                "website": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Alan Turing",
            
        
    
        
        
            
                "email": "Ada Lovelace",
            
        
    
        
        
            
                "billing_address": "Marie Curie",
            
        
    
        
        
            
                "shipping_address": "Ada Lovelace",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "legal_name": "Marie Curie",
            
        
    
        
        
            
                "tax_number": "Marie Curie",
            
        
    
        
        
            
                "industry": "Marie Curie",
            
        
    
        
        
            
                "website": "Ada Lovelace",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "email": "Ada Lovelace",
            
        
    
        
        
            
                "billing_address": "Grace Hopper",
            
        
    
        
        
            
                "shipping_address": "Grace Hopper",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ContactsData = [
    
    {
    
        
        
            
                "first_name": "Alan Turing",
            
        
    
        
        
            
                "last_name": "Alan Turing",
            
        
    
        
        
            
                "email": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Grace Hopper",
            
        
    
        
        
            
                "job_title": "Alan Turing",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "first_name": "Alan Turing",
            
        
    
        
        
            
                "last_name": "Marie Curie",
            
        
    
        
        
            
                "email": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Ada Lovelace",
            
        
    
        
        
            
                "job_title": "Marie Curie",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "first_name": "Marie Curie",
            
        
    
        
        
            
                "last_name": "Marie Curie",
            
        
    
        
        
            
                "email": "Ada Lovelace",
            
        
    
        
        
            
                "phone": "Grace Hopper",
            
        
    
        
        
            
                "job_title": "Alan Turing",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PipelinesData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "module": "event_planning",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_default": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "module": "event_planning",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_default": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "module": "sales_crm",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_default": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PipelineStagesData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sort_order": 6,
            
        
    
        
        
            
                "stage_type": "won",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "sort_order": 9,
            
        
    
        
        
            
                "stage_type": "lost",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sort_order": 5,
            
        
    
        
        
            
                "stage_type": "open",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const LeadsData = [
    
    {
    
        
        
            
                "title": "Alan Turing",
            
        
    
        
        
            
                "source": "website",
            
        
    
        
        
            
                "status": "qualified",
            
        
    
        
        
            
                "estimated_value": 2.8,
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "next_follow_up_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Ada Lovelace",
            
        
    
        
        
            
                "source": "event",
            
        
    
        
        
            
                "status": "qualified",
            
        
    
        
        
            
                "estimated_value": 1.72,
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "next_follow_up_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Alan Turing",
            
        
    
        
        
            
                "source": "phone",
            
        
    
        
        
            
                "status": "disqualified",
            
        
    
        
        
            
                "estimated_value": 1.36,
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "next_follow_up_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const DealsData = [
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "deal_type": "upsell",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "amount": 6.48,
            
        
    
        
        
            
                "probability": 7.34,
            
        
    
        
        
            
                "expected_close_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "deal_type": "new_business",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "amount": 6.77,
            
        
    
        
        
            
                "probability": 3.35,
            
        
    
        
        
            
                "expected_close_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "deal_type": "new_business",
            
        
    
        
        
            
                "status": "lost",
            
        
    
        
        
            
                "amount": 9.52,
            
        
    
        
        
            
                "probability": 7.5,
            
        
    
        
        
            
                "expected_close_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ActivitiesData = [
    
    {
    
        
        
            
                "activity_type": "meeting",
            
        
    
        
        
            
                "status": "done",
            
        
    
        
        
            
                "subject": "Grace Hopper",
            
        
    
        
        
            
                "details": "Ada Lovelace",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "activity_type": "note",
            
        
    
        
        
            
                "status": "canceled",
            
        
    
        
        
            
                "subject": "Alan Turing",
            
        
    
        
        
            
                "details": "Alan Turing",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "activity_type": "note",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "subject": "Ada Lovelace",
            
        
    
        
        
            
                "details": "Ada Lovelace",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const MaterialsData = [
    
    {
    
        
        
            
                "sku": "Marie Curie",
            
        
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "material_type": "consumable",
            
        
    
        
        
            
                "unit_of_measure": "Ada Lovelace",
            
        
    
        
        
            
                "standard_cost": 9.05,
            
        
    
        
        
            
                "reorder_point": 2.38,
            
        
    
        
        
            
                "reorder_quantity": 8.28,
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "specification": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "sku": "Grace Hopper",
            
        
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "material_type": "consumable",
            
        
    
        
        
            
                "unit_of_measure": "Ada Lovelace",
            
        
    
        
        
            
                "standard_cost": 4.14,
            
        
    
        
        
            
                "reorder_point": 3.22,
            
        
    
        
        
            
                "reorder_quantity": 0.27,
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "specification": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "sku": "Marie Curie",
            
        
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "material_type": "consumable",
            
        
    
        
        
            
                "unit_of_measure": "Alan Turing",
            
        
    
        
        
            
                "standard_cost": 3.52,
            
        
    
        
        
            
                "reorder_point": 6.67,
            
        
    
        
        
            
                "reorder_quantity": 9.44,
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "specification": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const WarehousesData = [
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "code": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "code": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "code": "Marie Curie",
            
        
    
        
        
            
                "address": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const InventoryItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "Grace Hopper",
            
        
    
        
        
            
                "serial_number": "Alan Turing",
            
        
    
        
        
            
                "quantity_on_hand": 1.65,
            
        
    
        
        
            
                "quantity_reserved": 5.75,
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "expires_at": new Date(Date.now()),
            
        
    
        
        
            
                "status": "consumed",
            
        
    
        
        
            
                "location_bin": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "Marie Curie",
            
        
    
        
        
            
                "serial_number": "Ada Lovelace",
            
        
    
        
        
            
                "quantity_on_hand": 2.87,
            
        
    
        
        
            
                "quantity_reserved": 4.94,
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "expires_at": new Date(Date.now()),
            
        
    
        
        
            
                "status": "reserved",
            
        
    
        
        
            
                "location_bin": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "Grace Hopper",
            
        
    
        
        
            
                "serial_number": "Ada Lovelace",
            
        
    
        
        
            
                "quantity_on_hand": 5.2,
            
        
    
        
        
            
                "quantity_reserved": 6.58,
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "expires_at": new Date(Date.now()),
            
        
    
        
        
            
                "status": "available",
            
        
    
        
        
            
                "location_bin": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const MachinesData = [
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "code": "Ada Lovelace",
            
        
    
        
        
            
                "machine_type": "other",
            
        
    
        
        
            
                "status": "in_use",
            
        
    
        
        
            
                "last_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "next_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "code": "Marie Curie",
            
        
    
        
        
            
                "machine_type": "laser",
            
        
    
        
        
            
                "status": "in_use",
            
        
    
        
        
            
                "last_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "next_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "code": "Marie Curie",
            
        
    
        
        
            
                "machine_type": "press",
            
        
    
        
        
            
                "status": "available",
            
        
    
        
        
            
                "last_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "next_maintenance_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ProductionOrdersData = [
    
    {
    
        
        
            
                "order_number": "Grace Hopper",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "planned_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "planned_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Alan Turing",
            
        
    
        
        
            
                "status": "canceled",
            
        
    
        
        
            
                "planned_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "planned_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Ada Lovelace",
            
        
    
        
        
            
                "status": "canceled",
            
        
    
        
        
            
                "planned_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "planned_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "actual_end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ProductionOperationsData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sequence": 9,
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "scheduled_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "scheduled_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_quantity": 0.52,
            
        
    
        
        
            
                "good_quantity": 6.19,
            
        
    
        
        
            
                "scrap_quantity": 2.83,
            
        
    
        
        
            
                "work_instructions": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sequence": 7,
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "scheduled_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "scheduled_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_quantity": 7.87,
            
        
    
        
        
            
                "good_quantity": 6.51,
            
        
    
        
        
            
                "scrap_quantity": 7.71,
            
        
    
        
        
            
                "work_instructions": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sequence": 3,
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "scheduled_start_at": new Date(Date.now()),
            
        
    
        
        
            
                "scheduled_end_at": new Date(Date.now()),
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_quantity": 4.82,
            
        
    
        
        
            
                "good_quantity": 1.9,
            
        
    
        
        
            
                "scrap_quantity": 1.89,
            
        
    
        
        
            
                "work_instructions": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const QualityInspectionsData = [
    
    {
    
        
        
            
                "inspection_number": "Marie Curie",
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                "result": "pending",
            
        
    
        
        
            
                "scheduled_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "findings": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "Marie Curie",
            
        
    
        
        
            
                "inspection_type": "audit",
            
        
    
        
        
            
                "result": "rework_required",
            
        
    
        
        
            
                "scheduled_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "findings": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "Marie Curie",
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                "result": "rework_required",
            
        
    
        
        
            
                "scheduled_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "findings": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const NonconformancesData = [
    
    {
    
        
        
            
                "ncr_number": "Marie Curie",
            
        
    
        
        
            
                "severity": "major",
            
        
    
        
        
            
                "status": "corrective_action",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                "root_cause": "Marie Curie",
            
        
    
        
        
            
                "corrective_action": "Grace Hopper",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "Ada Lovelace",
            
        
    
        
        
            
                "severity": "major",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                "root_cause": "Marie Curie",
            
        
    
        
        
            
                "corrective_action": "Grace Hopper",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "Ada Lovelace",
            
        
    
        
        
            
                "severity": "major",
            
        
    
        
        
            
                "status": "contained",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                "root_cause": "Ada Lovelace",
            
        
    
        
        
            
                "corrective_action": "Grace Hopper",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "closed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const VendorsData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "email": "Marie Curie",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "website": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "vendor_type": "av",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "email": "Alan Turing",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "website": "Grace Hopper",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "vendor_type": "venue",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "email": "Marie Curie",
            
        
    
        
        
            
                "phone": "Alan Turing",
            
        
    
        
        
            
                "website": "Grace Hopper",
            
        
    
        
        
            
                "address": "Alan Turing",
            
        
    
        
        
            
                "vendor_type": "other",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const VenuesData = [
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "address": "Ada Lovelace",
            
        
    
        
        
            
                "city": "Marie Curie",
            
        
    
        
        
            
                "country": "Alan Turing",
            
        
    
        
        
            
                "capacity": 6,
            
        
    
        
        
            
                "contact_name": "Ada Lovelace",
            
        
    
        
        
            
                "contact_phone": "Ada Lovelace",
            
        
    
        
        
            
                "contact_email": "Marie Curie",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "city": "Ada Lovelace",
            
        
    
        
        
            
                "country": "Grace Hopper",
            
        
    
        
        
            
                "capacity": 9,
            
        
    
        
        
            
                "contact_name": "Ada Lovelace",
            
        
    
        
        
            
                "contact_phone": "Grace Hopper",
            
        
    
        
        
            
                "contact_email": "Ada Lovelace",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "city": "Marie Curie",
            
        
    
        
        
            
                "country": "Grace Hopper",
            
        
    
        
        
            
                "capacity": 4,
            
        
    
        
        
            
                "contact_name": "Alan Turing",
            
        
    
        
        
            
                "contact_phone": "Ada Lovelace",
            
        
    
        
        
            
                "contact_email": "Marie Curie",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const EventsData = [
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "budget_total": 1.71,
            
        
    
        
        
            
                "budget_spent": 7.84,
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "budget_total": 9.05,
            
        
    
        
        
            
                "budget_spent": 2.02,
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "status": "canceled",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "budget_total": 1.76,
            
        
    
        
        
            
                "budget_spent": 6.78,
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const EventTasksData = [
    
    {
    
        
        
            
                "title": "Marie Curie",
            
        
    
        
        
            
                "status": "blocked",
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "details": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Alan Turing",
            
        
    
        
        
            
                "status": "done",
            
        
    
        
        
            
                "priority": "medium",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "details": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Ada Lovelace",
            
        
    
        
        
            
                "status": "blocked",
            
        
    
        
        
            
                "priority": "medium",
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "details": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const EventGuestsData = [
    
    {
    
        
        
            
                "full_name": "Ada Lovelace",
            
        
    
        
        
            
                "email": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "rsvp_status": "checked_in",
            
        
    
        
        
            
                "guest_type": "regular",
            
        
    
        
        
            
                "invited_at": new Date(Date.now()),
            
        
    
        
        
            
                "checked_in_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "full_name": "Ada Lovelace",
            
        
    
        
        
            
                "email": "Alan Turing",
            
        
    
        
        
            
                "phone": "Ada Lovelace",
            
        
    
        
        
            
                "rsvp_status": "checked_in",
            
        
    
        
        
            
                "guest_type": "regular",
            
        
    
        
        
            
                "invited_at": new Date(Date.now()),
            
        
    
        
        
            
                "checked_in_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "full_name": "Grace Hopper",
            
        
    
        
        
            
                "email": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "rsvp_status": "declined",
            
        
    
        
        
            
                "guest_type": "staff",
            
        
    
        
        
            
                "invited_at": new Date(Date.now()),
            
        
    
        
        
            
                "checked_in_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const EventScheduleItemsData = [
    
    {
    
        
        
            
                "title": "Alan Turing",
            
        
    
        
        
            
                "status": "canceled",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location": "Ada Lovelace",
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Marie Curie",
            
        
    
        
        
            
                "status": "confirmed",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location": "Alan Turing",
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "title": "Ada Lovelace",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "start_at": new Date(Date.now()),
            
        
    
        
        
            
                "end_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location": "Alan Turing",
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const BudgetItemsData = [
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "category": "materials",
            
        
    
        
        
            
                "status": "paid",
            
        
    
        
        
            
                "estimated_cost": 7.76,
            
        
    
        
        
            
                "actual_cost": 0.45,
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "paid_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "category": "materials",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "estimated_cost": 1.78,
            
        
    
        
        
            
                "actual_cost": 6.55,
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "paid_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "category": "catering",
            
        
    
        
        
            
                "status": "committed",
            
        
    
        
        
            
                "estimated_cost": 2.1,
            
        
    
        
        
            
                "actual_cost": 9.4,
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "paid_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            
            async function associateUserWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User0 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (User0?.setOrganization)
                {
                    await
                    User0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User1 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (User1?.setOrganization)
                {
                    await
                    User1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User2 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (User2?.setOrganization)
                {
                    await
                    User2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
    
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateCompanyWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Company0 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Company0?.setOwner)
                {
                    await
                    Company0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Company1 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Company1?.setOwner)
                {
                    await
                    Company1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Company2 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Company2?.setOwner)
                {
                    await
                    Company2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
            
            async function associateCompanyWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Company0 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Company0?.setOrganization)
                {
                    await
                    Company0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Company1 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Company1?.setOrganization)
                {
                    await
                    Company1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Company2 = await Companies.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Company2?.setOrganization)
                {
                    await
                    Company2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateContactWithCompany() {
            
                const relatedCompany0 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Contact0 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Contact0?.setCompany)
                {
                    await
                    Contact0.
                    setCompany(relatedCompany0);
                }
            
                const relatedCompany1 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Contact1 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Contact1?.setCompany)
                {
                    await
                    Contact1.
                    setCompany(relatedCompany1);
                }
            
                const relatedCompany2 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Contact2 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Contact2?.setCompany)
                {
                    await
                    Contact2.
                    setCompany(relatedCompany2);
                }
            
        }
        
    
        
            
            async function associateContactWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Contact0 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Contact0?.setOwner)
                {
                    await
                    Contact0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Contact1 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Contact1?.setOwner)
                {
                    await
                    Contact1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Contact2 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Contact2?.setOwner)
                {
                    await
                    Contact2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
            
            async function associateContactWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Contact0 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Contact0?.setOrganization)
                {
                    await
                    Contact0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Contact1 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Contact1?.setOrganization)
                {
                    await
                    Contact1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Contact2 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Contact2?.setOrganization)
                {
                    await
                    Contact2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
            
            async function associatePipelineWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Pipeline0 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Pipeline0?.setOwner)
                {
                    await
                    Pipeline0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Pipeline1 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Pipeline1?.setOwner)
                {
                    await
                    Pipeline1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Pipeline2 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Pipeline2?.setOwner)
                {
                    await
                    Pipeline2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
            
            async function associatePipelineWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Pipeline0 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Pipeline0?.setOrganization)
                {
                    await
                    Pipeline0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Pipeline1 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Pipeline1?.setOrganization)
                {
                    await
                    Pipeline1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Pipeline2 = await Pipelines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Pipeline2?.setOrganization)
                {
                    await
                    Pipeline2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associatePipelineStageWithPipeline() {
            
                const relatedPipeline0 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const PipelineStage0 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PipelineStage0?.setPipeline)
                {
                    await
                    PipelineStage0.
                    setPipeline(relatedPipeline0);
                }
            
                const relatedPipeline1 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const PipelineStage1 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PipelineStage1?.setPipeline)
                {
                    await
                    PipelineStage1.
                    setPipeline(relatedPipeline1);
                }
            
                const relatedPipeline2 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const PipelineStage2 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PipelineStage2?.setPipeline)
                {
                    await
                    PipelineStage2.
                    setPipeline(relatedPipeline2);
                }
            
        }
        
    
        
    
        
            
            async function associatePipelineStageWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PipelineStage0 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PipelineStage0?.setOrganization)
                {
                    await
                    PipelineStage0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PipelineStage1 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PipelineStage1?.setOrganization)
                {
                    await
                    PipelineStage1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PipelineStage2 = await PipelineStages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PipelineStage2?.setOrganization)
                {
                    await
                    PipelineStage2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateLeadWithCompany() {
            
                const relatedCompany0 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setCompany)
                {
                    await
                    Lead0.
                    setCompany(relatedCompany0);
                }
            
                const relatedCompany1 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setCompany)
                {
                    await
                    Lead1.
                    setCompany(relatedCompany1);
                }
            
                const relatedCompany2 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setCompany)
                {
                    await
                    Lead2.
                    setCompany(relatedCompany2);
                }
            
        }
        
    
        
            
            async function associateLeadWithPrimary_contact() {
            
                const relatedPrimary_contact0 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setPrimary_contact)
                {
                    await
                    Lead0.
                    setPrimary_contact(relatedPrimary_contact0);
                }
            
                const relatedPrimary_contact1 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setPrimary_contact)
                {
                    await
                    Lead1.
                    setPrimary_contact(relatedPrimary_contact1);
                }
            
                const relatedPrimary_contact2 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setPrimary_contact)
                {
                    await
                    Lead2.
                    setPrimary_contact(relatedPrimary_contact2);
                }
            
        }
        
    
        
            
            async function associateLeadWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setOwner)
                {
                    await
                    Lead0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setOwner)
                {
                    await
                    Lead1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setOwner)
                {
                    await
                    Lead2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
            
            async function associateLeadWithPipeline() {
            
                const relatedPipeline0 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setPipeline)
                {
                    await
                    Lead0.
                    setPipeline(relatedPipeline0);
                }
            
                const relatedPipeline1 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setPipeline)
                {
                    await
                    Lead1.
                    setPipeline(relatedPipeline1);
                }
            
                const relatedPipeline2 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setPipeline)
                {
                    await
                    Lead2.
                    setPipeline(relatedPipeline2);
                }
            
        }
        
    
        
            
            async function associateLeadWithStage() {
            
                const relatedStage0 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setStage)
                {
                    await
                    Lead0.
                    setStage(relatedStage0);
                }
            
                const relatedStage1 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setStage)
                {
                    await
                    Lead1.
                    setStage(relatedStage1);
                }
            
                const relatedStage2 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setStage)
                {
                    await
                    Lead2.
                    setStage(relatedStage2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateLeadWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setOrganization)
                {
                    await
                    Lead0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setOrganization)
                {
                    await
                    Lead1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setOrganization)
                {
                    await
                    Lead2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDealWithCompany() {
            
                const relatedCompany0 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setCompany)
                {
                    await
                    Deal0.
                    setCompany(relatedCompany0);
                }
            
                const relatedCompany1 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setCompany)
                {
                    await
                    Deal1.
                    setCompany(relatedCompany1);
                }
            
                const relatedCompany2 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setCompany)
                {
                    await
                    Deal2.
                    setCompany(relatedCompany2);
                }
            
        }
        
    
        
            
            async function associateDealWithPrimary_contact() {
            
                const relatedPrimary_contact0 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setPrimary_contact)
                {
                    await
                    Deal0.
                    setPrimary_contact(relatedPrimary_contact0);
                }
            
                const relatedPrimary_contact1 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setPrimary_contact)
                {
                    await
                    Deal1.
                    setPrimary_contact(relatedPrimary_contact1);
                }
            
                const relatedPrimary_contact2 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setPrimary_contact)
                {
                    await
                    Deal2.
                    setPrimary_contact(relatedPrimary_contact2);
                }
            
        }
        
    
        
            
            async function associateDealWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setOwner)
                {
                    await
                    Deal0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setOwner)
                {
                    await
                    Deal1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setOwner)
                {
                    await
                    Deal2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
            
            async function associateDealWithPipeline() {
            
                const relatedPipeline0 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setPipeline)
                {
                    await
                    Deal0.
                    setPipeline(relatedPipeline0);
                }
            
                const relatedPipeline1 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setPipeline)
                {
                    await
                    Deal1.
                    setPipeline(relatedPipeline1);
                }
            
                const relatedPipeline2 = await Pipelines.findOne({
                    offset: Math.floor(Math.random() * (await Pipelines.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setPipeline)
                {
                    await
                    Deal2.
                    setPipeline(relatedPipeline2);
                }
            
        }
        
    
        
            
            async function associateDealWithStage() {
            
                const relatedStage0 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setStage)
                {
                    await
                    Deal0.
                    setStage(relatedStage0);
                }
            
                const relatedStage1 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setStage)
                {
                    await
                    Deal1.
                    setStage(relatedStage1);
                }
            
                const relatedStage2 = await PipelineStages.findOne({
                    offset: Math.floor(Math.random() * (await PipelineStages.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setStage)
                {
                    await
                    Deal2.
                    setStage(relatedStage2);
                }
            
        }
        
    
        
            
            async function associateDealWithLead() {
            
                const relatedLead0 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setLead)
                {
                    await
                    Deal0.
                    setLead(relatedLead0);
                }
            
                const relatedLead1 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setLead)
                {
                    await
                    Deal1.
                    setLead(relatedLead1);
                }
            
                const relatedLead2 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setLead)
                {
                    await
                    Deal2.
                    setLead(relatedLead2);
                }
            
        }
        
    
        
    
        
            
            async function associateDealWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Deal0 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Deal0?.setOrganization)
                {
                    await
                    Deal0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Deal1 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Deal1?.setOrganization)
                {
                    await
                    Deal1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Deal2 = await Deals.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Deal2?.setOrganization)
                {
                    await
                    Deal2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateActivityWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setAssigned_to)
                {
                    await
                    Activity0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setAssigned_to)
                {
                    await
                    Activity1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setAssigned_to)
                {
                    await
                    Activity2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
        }
        
    
        
            
            async function associateActivityWithCompany() {
            
                const relatedCompany0 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setCompany)
                {
                    await
                    Activity0.
                    setCompany(relatedCompany0);
                }
            
                const relatedCompany1 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setCompany)
                {
                    await
                    Activity1.
                    setCompany(relatedCompany1);
                }
            
                const relatedCompany2 = await Companies.findOne({
                    offset: Math.floor(Math.random() * (await Companies.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setCompany)
                {
                    await
                    Activity2.
                    setCompany(relatedCompany2);
                }
            
        }
        
    
        
            
            async function associateActivityWithContact() {
            
                const relatedContact0 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setContact)
                {
                    await
                    Activity0.
                    setContact(relatedContact0);
                }
            
                const relatedContact1 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setContact)
                {
                    await
                    Activity1.
                    setContact(relatedContact1);
                }
            
                const relatedContact2 = await Contacts.findOne({
                    offset: Math.floor(Math.random() * (await Contacts.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setContact)
                {
                    await
                    Activity2.
                    setContact(relatedContact2);
                }
            
        }
        
    
        
            
            async function associateActivityWithLead() {
            
                const relatedLead0 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setLead)
                {
                    await
                    Activity0.
                    setLead(relatedLead0);
                }
            
                const relatedLead1 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setLead)
                {
                    await
                    Activity1.
                    setLead(relatedLead1);
                }
            
                const relatedLead2 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setLead)
                {
                    await
                    Activity2.
                    setLead(relatedLead2);
                }
            
        }
        
    
        
            
            async function associateActivityWithDeal() {
            
                const relatedDeal0 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setDeal)
                {
                    await
                    Activity0.
                    setDeal(relatedDeal0);
                }
            
                const relatedDeal1 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setDeal)
                {
                    await
                    Activity1.
                    setDeal(relatedDeal1);
                }
            
                const relatedDeal2 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setDeal)
                {
                    await
                    Activity2.
                    setDeal(relatedDeal2);
                }
            
        }
        
    
        
    
        
            
            async function associateActivityWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Activity0 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Activity0?.setOrganization)
                {
                    await
                    Activity0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Activity1 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Activity1?.setOrganization)
                {
                    await
                    Activity1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Activity2 = await Activities.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Activity2?.setOrganization)
                {
                    await
                    Activity2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMaterialWithPreferred_vendor() {
            
                const relatedPreferred_vendor0 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Material0 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Material0?.setPreferred_vendor)
                {
                    await
                    Material0.
                    setPreferred_vendor(relatedPreferred_vendor0);
                }
            
                const relatedPreferred_vendor1 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Material1 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Material1?.setPreferred_vendor)
                {
                    await
                    Material1.
                    setPreferred_vendor(relatedPreferred_vendor1);
                }
            
                const relatedPreferred_vendor2 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Material2 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Material2?.setPreferred_vendor)
                {
                    await
                    Material2.
                    setPreferred_vendor(relatedPreferred_vendor2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateMaterialWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Material0 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Material0?.setOrganization)
                {
                    await
                    Material0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Material1 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Material1?.setOrganization)
                {
                    await
                    Material1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Material2 = await Materials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Material2?.setOrganization)
                {
                    await
                    Material2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateWarehousWithManager() {
            
                const relatedManager0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Warehous0 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Warehous0?.setManager)
                {
                    await
                    Warehous0.
                    setManager(relatedManager0);
                }
            
                const relatedManager1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Warehous1 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Warehous1?.setManager)
                {
                    await
                    Warehous1.
                    setManager(relatedManager1);
                }
            
                const relatedManager2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Warehous2 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Warehous2?.setManager)
                {
                    await
                    Warehous2.
                    setManager(relatedManager2);
                }
            
        }
        
    
        
    
        
            
            async function associateWarehousWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Warehous0 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Warehous0?.setOrganization)
                {
                    await
                    Warehous0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Warehous1 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Warehous1?.setOrganization)
                {
                    await
                    Warehous1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Warehous2 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Warehous2?.setOrganization)
                {
                    await
                    Warehous2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateInventoryItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setMaterial)
                {
                    await
                    InventoryItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setMaterial)
                {
                    await
                    InventoryItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setMaterial)
                {
                    await
                    InventoryItem2.
                    setMaterial(relatedMaterial2);
                }
            
        }
        
    
        
            
            async function associateInventoryItemWithWarehouse() {
            
                const relatedWarehouse0 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setWarehouse)
                {
                    await
                    InventoryItem0.
                    setWarehouse(relatedWarehouse0);
                }
            
                const relatedWarehouse1 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setWarehouse)
                {
                    await
                    InventoryItem1.
                    setWarehouse(relatedWarehouse1);
                }
            
                const relatedWarehouse2 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setWarehouse)
                {
                    await
                    InventoryItem2.
                    setWarehouse(relatedWarehouse2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateInventoryItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setOrganization)
                {
                    await
                    InventoryItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setOrganization)
                {
                    await
                    InventoryItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setOrganization)
                {
                    await
                    InventoryItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMachineWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Machine0 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Machine0?.setOwner)
                {
                    await
                    Machine0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Machine1 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Machine1?.setOwner)
                {
                    await
                    Machine1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Machine2 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Machine2?.setOwner)
                {
                    await
                    Machine2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
            
            async function associateMachineWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Machine0 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Machine0?.setOrganization)
                {
                    await
                    Machine0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Machine1 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Machine1?.setOrganization)
                {
                    await
                    Machine1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Machine2 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Machine2?.setOrganization)
                {
                    await
                    Machine2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductionOrderWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setOwner)
                {
                    await
                    ProductionOrder0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setOwner)
                {
                    await
                    ProductionOrder1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setOwner)
                {
                    await
                    ProductionOrder2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithDeal() {
            
                const relatedDeal0 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setDeal)
                {
                    await
                    ProductionOrder0.
                    setDeal(relatedDeal0);
                }
            
                const relatedDeal1 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setDeal)
                {
                    await
                    ProductionOrder1.
                    setDeal(relatedDeal1);
                }
            
                const relatedDeal2 = await Deals.findOne({
                    offset: Math.floor(Math.random() * (await Deals.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setDeal)
                {
                    await
                    ProductionOrder2.
                    setDeal(relatedDeal2);
                }
            
        }
        
    
        
    
        
            
            async function associateProductionOrderWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setOrganization)
                {
                    await
                    ProductionOrder0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setOrganization)
                {
                    await
                    ProductionOrder1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setOrganization)
                {
                    await
                    ProductionOrder2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            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 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 associateProductionOperationWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setAssigned_to)
                {
                    await
                    ProductionOperation0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setAssigned_to)
                {
                    await
                    ProductionOperation1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setAssigned_to)
                {
                    await
                    ProductionOperation2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductionOperationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setOrganization)
                {
                    await
                    ProductionOperation0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setOrganization)
                {
                    await
                    ProductionOperation1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setOrganization)
                {
                    await
                    ProductionOperation2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateQualityInspectionWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QualityInspection0 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityInspection0?.setProduction_order)
                {
                    await
                    QualityInspection0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QualityInspection1 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityInspection1?.setProduction_order)
                {
                    await
                    QualityInspection1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QualityInspection2 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityInspection2?.setProduction_order)
                {
                    await
                    QualityInspection2.
                    setProduction_order(relatedProduction_order2);
                }
            
        }
        
    
        
            
            async function associateQualityInspectionWithOperation() {
            
                const relatedOperation0 = await ProductionOperations.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOperations.count())),
                });
                const QualityInspection0 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityInspection0?.setOperation)
                {
                    await
                    QualityInspection0.
                    setOperation(relatedOperation0);
                }
            
                const relatedOperation1 = await ProductionOperations.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOperations.count())),
                });
                const QualityInspection1 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityInspection1?.setOperation)
                {
                    await
                    QualityInspection1.
                    setOperation(relatedOperation1);
                }
            
                const relatedOperation2 = await ProductionOperations.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOperations.count())),
                });
                const QualityInspection2 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityInspection2?.setOperation)
                {
                    await
                    QualityInspection2.
                    setOperation(relatedOperation2);
                }
            
        }
        
    
        
            
            async function associateQualityInspectionWithInspector() {
            
                const relatedInspector0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityInspection0 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityInspection0?.setInspector)
                {
                    await
                    QualityInspection0.
                    setInspector(relatedInspector0);
                }
            
                const relatedInspector1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityInspection1 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityInspection1?.setInspector)
                {
                    await
                    QualityInspection1.
                    setInspector(relatedInspector1);
                }
            
                const relatedInspector2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QualityInspection2 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityInspection2?.setInspector)
                {
                    await
                    QualityInspection2.
                    setInspector(relatedInspector2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateQualityInspectionWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const QualityInspection0 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QualityInspection0?.setOrganization)
                {
                    await
                    QualityInspection0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const QualityInspection1 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QualityInspection1?.setOrganization)
                {
                    await
                    QualityInspection1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const QualityInspection2 = await QualityInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QualityInspection2?.setOrganization)
                {
                    await
                    QualityInspection2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithInspection() {
            
                const relatedInspection0 = await QualityInspections.findOne({
                    offset: Math.floor(Math.random() * (await QualityInspections.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setInspection)
                {
                    await
                    Nonconformance0.
                    setInspection(relatedInspection0);
                }
            
                const relatedInspection1 = await QualityInspections.findOne({
                    offset: Math.floor(Math.random() * (await QualityInspections.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setInspection)
                {
                    await
                    Nonconformance1.
                    setInspection(relatedInspection1);
                }
            
                const relatedInspection2 = await QualityInspections.findOne({
                    offset: Math.floor(Math.random() * (await QualityInspections.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setInspection)
                {
                    await
                    Nonconformance2.
                    setInspection(relatedInspection2);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setOwner)
                {
                    await
                    Nonconformance0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setOwner)
                {
                    await
                    Nonconformance1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setOwner)
                {
                    await
                    Nonconformance2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setOrganization)
                {
                    await
                    Nonconformance0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setOrganization)
                {
                    await
                    Nonconformance1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setOrganization)
                {
                    await
                    Nonconformance2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateVendorWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Vendor0 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Vendor0?.setOwner)
                {
                    await
                    Vendor0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Vendor1 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Vendor1?.setOwner)
                {
                    await
                    Vendor1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Vendor2 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Vendor2?.setOwner)
                {
                    await
                    Vendor2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
            
            async function associateVendorWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Vendor0 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Vendor0?.setOrganization)
                {
                    await
                    Vendor0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Vendor1 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Vendor1?.setOrganization)
                {
                    await
                    Vendor1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Vendor2 = await Vendors.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Vendor2?.setOrganization)
                {
                    await
                    Vendor2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateVenueWithPreferred_vendor() {
            
                const relatedPreferred_vendor0 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Venue0 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Venue0?.setPreferred_vendor)
                {
                    await
                    Venue0.
                    setPreferred_vendor(relatedPreferred_vendor0);
                }
            
                const relatedPreferred_vendor1 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Venue1 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Venue1?.setPreferred_vendor)
                {
                    await
                    Venue1.
                    setPreferred_vendor(relatedPreferred_vendor1);
                }
            
                const relatedPreferred_vendor2 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const Venue2 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Venue2?.setPreferred_vendor)
                {
                    await
                    Venue2.
                    setPreferred_vendor(relatedPreferred_vendor2);
                }
            
        }
        
    
        
    
        
            
            async function associateVenueWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Venue0 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Venue0?.setOrganization)
                {
                    await
                    Venue0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Venue1 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Venue1?.setOrganization)
                {
                    await
                    Venue1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Venue2 = await Venues.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Venue2?.setOrganization)
                {
                    await
                    Venue2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateEventWithVenue() {
            
                const relatedVenue0 = await Venues.findOne({
                    offset: Math.floor(Math.random() * (await Venues.count())),
                });
                const Event0 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Event0?.setVenue)
                {
                    await
                    Event0.
                    setVenue(relatedVenue0);
                }
            
                const relatedVenue1 = await Venues.findOne({
                    offset: Math.floor(Math.random() * (await Venues.count())),
                });
                const Event1 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Event1?.setVenue)
                {
                    await
                    Event1.
                    setVenue(relatedVenue1);
                }
            
                const relatedVenue2 = await Venues.findOne({
                    offset: Math.floor(Math.random() * (await Venues.count())),
                });
                const Event2 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Event2?.setVenue)
                {
                    await
                    Event2.
                    setVenue(relatedVenue2);
                }
            
        }
        
    
        
            
            async function associateEventWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Event0 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Event0?.setOwner)
                {
                    await
                    Event0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Event1 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Event1?.setOwner)
                {
                    await
                    Event1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Event2 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Event2?.setOwner)
                {
                    await
                    Event2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateEventWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Event0 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Event0?.setOrganization)
                {
                    await
                    Event0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Event1 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Event1?.setOrganization)
                {
                    await
                    Event1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Event2 = await Events.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Event2?.setOrganization)
                {
                    await
                    Event2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateEventTaskWithEvent() {
            
                const relatedEvent0 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventTask0 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventTask0?.setEvent)
                {
                    await
                    EventTask0.
                    setEvent(relatedEvent0);
                }
            
                const relatedEvent1 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventTask1 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventTask1?.setEvent)
                {
                    await
                    EventTask1.
                    setEvent(relatedEvent1);
                }
            
                const relatedEvent2 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventTask2 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventTask2?.setEvent)
                {
                    await
                    EventTask2.
                    setEvent(relatedEvent2);
                }
            
        }
        
    
        
            
            async function associateEventTaskWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventTask0 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventTask0?.setAssigned_to)
                {
                    await
                    EventTask0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventTask1 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventTask1?.setAssigned_to)
                {
                    await
                    EventTask1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventTask2 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventTask2?.setAssigned_to)
                {
                    await
                    EventTask2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
        }
        
    
        
            
            async function associateEventTaskWithVendor() {
            
                const relatedVendor0 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const EventTask0 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventTask0?.setVendor)
                {
                    await
                    EventTask0.
                    setVendor(relatedVendor0);
                }
            
                const relatedVendor1 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const EventTask1 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventTask1?.setVendor)
                {
                    await
                    EventTask1.
                    setVendor(relatedVendor1);
                }
            
                const relatedVendor2 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const EventTask2 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventTask2?.setVendor)
                {
                    await
                    EventTask2.
                    setVendor(relatedVendor2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateEventTaskWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventTask0 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventTask0?.setOrganization)
                {
                    await
                    EventTask0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventTask1 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventTask1?.setOrganization)
                {
                    await
                    EventTask1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventTask2 = await EventTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventTask2?.setOrganization)
                {
                    await
                    EventTask2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateEventGuestWithEvent() {
            
                const relatedEvent0 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventGuest0 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventGuest0?.setEvent)
                {
                    await
                    EventGuest0.
                    setEvent(relatedEvent0);
                }
            
                const relatedEvent1 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventGuest1 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventGuest1?.setEvent)
                {
                    await
                    EventGuest1.
                    setEvent(relatedEvent1);
                }
            
                const relatedEvent2 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventGuest2 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventGuest2?.setEvent)
                {
                    await
                    EventGuest2.
                    setEvent(relatedEvent2);
                }
            
        }
        
    
        
    
        
            
            async function associateEventGuestWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventGuest0 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventGuest0?.setOrganization)
                {
                    await
                    EventGuest0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventGuest1 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventGuest1?.setOrganization)
                {
                    await
                    EventGuest1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventGuest2 = await EventGuests.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventGuest2?.setOrganization)
                {
                    await
                    EventGuest2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateEventScheduleItemWithEvent() {
            
                const relatedEvent0 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventScheduleItem0 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventScheduleItem0?.setEvent)
                {
                    await
                    EventScheduleItem0.
                    setEvent(relatedEvent0);
                }
            
                const relatedEvent1 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventScheduleItem1 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventScheduleItem1?.setEvent)
                {
                    await
                    EventScheduleItem1.
                    setEvent(relatedEvent1);
                }
            
                const relatedEvent2 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const EventScheduleItem2 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventScheduleItem2?.setEvent)
                {
                    await
                    EventScheduleItem2.
                    setEvent(relatedEvent2);
                }
            
        }
        
    
        
            
            async function associateEventScheduleItemWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventScheduleItem0 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventScheduleItem0?.setOwner)
                {
                    await
                    EventScheduleItem0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventScheduleItem1 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventScheduleItem1?.setOwner)
                {
                    await
                    EventScheduleItem1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EventScheduleItem2 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventScheduleItem2?.setOwner)
                {
                    await
                    EventScheduleItem2.
                    setOwner(relatedOwner2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateEventScheduleItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventScheduleItem0 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EventScheduleItem0?.setOrganization)
                {
                    await
                    EventScheduleItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventScheduleItem1 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EventScheduleItem1?.setOrganization)
                {
                    await
                    EventScheduleItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EventScheduleItem2 = await EventScheduleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EventScheduleItem2?.setOrganization)
                {
                    await
                    EventScheduleItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateBudgetItemWithEvent() {
            
                const relatedEvent0 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const BudgetItem0 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BudgetItem0?.setEvent)
                {
                    await
                    BudgetItem0.
                    setEvent(relatedEvent0);
                }
            
                const relatedEvent1 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const BudgetItem1 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BudgetItem1?.setEvent)
                {
                    await
                    BudgetItem1.
                    setEvent(relatedEvent1);
                }
            
                const relatedEvent2 = await Events.findOne({
                    offset: Math.floor(Math.random() * (await Events.count())),
                });
                const BudgetItem2 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BudgetItem2?.setEvent)
                {
                    await
                    BudgetItem2.
                    setEvent(relatedEvent2);
                }
            
        }
        
    
        
            
            async function associateBudgetItemWithVendor() {
            
                const relatedVendor0 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const BudgetItem0 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BudgetItem0?.setVendor)
                {
                    await
                    BudgetItem0.
                    setVendor(relatedVendor0);
                }
            
                const relatedVendor1 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const BudgetItem1 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BudgetItem1?.setVendor)
                {
                    await
                    BudgetItem1.
                    setVendor(relatedVendor1);
                }
            
                const relatedVendor2 = await Vendors.findOne({
                    offset: Math.floor(Math.random() * (await Vendors.count())),
                });
                const BudgetItem2 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BudgetItem2?.setVendor)
                {
                    await
                    BudgetItem2.
                    setVendor(relatedVendor2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateBudgetItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const BudgetItem0 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BudgetItem0?.setOrganization)
                {
                    await
                    BudgetItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const BudgetItem1 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BudgetItem1?.setOrganization)
                {
                    await
                    BudgetItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const BudgetItem2 = await BudgetItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BudgetItem2?.setOrganization)
                {
                    await
                    BudgetItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Organizations.bulkCreate(OrganizationsData);
                
            
            
                
                await Companies.bulkCreate(CompaniesData);
                
            
            
                
                await Contacts.bulkCreate(ContactsData);
                
            
            
                
                await Pipelines.bulkCreate(PipelinesData);
                
            
            
                
                await PipelineStages.bulkCreate(PipelineStagesData);
                
            
            
                
                await Leads.bulkCreate(LeadsData);
                
            
            
                
                await Deals.bulkCreate(DealsData);
                
            
            
                
                await Activities.bulkCreate(ActivitiesData);
                
            
            
                
                await Materials.bulkCreate(MaterialsData);
                
            
            
                
                await Warehouses.bulkCreate(WarehousesData);
                
            
            
                
                await InventoryItems.bulkCreate(InventoryItemsData);
                
            
            
                
                await Machines.bulkCreate(MachinesData);
                
            
            
                
                await ProductionOrders.bulkCreate(ProductionOrdersData);
                
            
            
                
                await ProductionOperations.bulkCreate(ProductionOperationsData);
                
            
            
                
                await QualityInspections.bulkCreate(QualityInspectionsData);
                
            
            
                
                await Nonconformances.bulkCreate(NonconformancesData);
                
            
            
                
                await Vendors.bulkCreate(VendorsData);
                
            
            
                
                await Venues.bulkCreate(VenuesData);
                
            
            
                
                await Events.bulkCreate(EventsData);
                
            
            
                
                await EventTasks.bulkCreate(EventTasksData);
                
            
            
                
                await EventGuests.bulkCreate(EventGuestsData);
                
            
            
                
                await EventScheduleItems.bulkCreate(EventScheduleItemsData);
                
            
            
                
                await BudgetItems.bulkCreate(BudgetItemsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateUserWithOrganization(),
                    
                
            
                
                
                
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCompanyWithOwner(),
                    
                
                    
                        
                        await associateCompanyWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateContactWithCompany(),
                    
                
                    
                        
                        await associateContactWithOwner(),
                    
                
                    
                
                    
                        
                        await associateContactWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associatePipelineWithOwner(),
                    
                
                    
                
                    
                        
                        await associatePipelineWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePipelineStageWithPipeline(),
                    
                
                    
                
                    
                        
                        await associatePipelineStageWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateLeadWithCompany(),
                    
                
                    
                        
                        await associateLeadWithPrimary_contact(),
                    
                
                    
                        
                        await associateLeadWithOwner(),
                    
                
                    
                        
                        await associateLeadWithPipeline(),
                    
                
                    
                        
                        await associateLeadWithStage(),
                    
                
                    
                
                    
                
                    
                        
                        await associateLeadWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDealWithCompany(),
                    
                
                    
                        
                        await associateDealWithPrimary_contact(),
                    
                
                    
                        
                        await associateDealWithOwner(),
                    
                
                    
                        
                        await associateDealWithPipeline(),
                    
                
                    
                        
                        await associateDealWithStage(),
                    
                
                    
                        
                        await associateDealWithLead(),
                    
                
                    
                
                    
                        
                        await associateDealWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateActivityWithAssigned_to(),
                    
                
                    
                        
                        await associateActivityWithCompany(),
                    
                
                    
                        
                        await associateActivityWithContact(),
                    
                
                    
                        
                        await associateActivityWithLead(),
                    
                
                    
                        
                        await associateActivityWithDeal(),
                    
                
                    
                
                    
                        
                        await associateActivityWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMaterialWithPreferred_vendor(),
                    
                
                    
                
                    
                
                    
                        
                        await associateMaterialWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateWarehousWithManager(),
                    
                
                    
                
                    
                        
                        await associateWarehousWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateInventoryItemWithMaterial(),
                    
                
                    
                        
                        await associateInventoryItemWithWarehouse(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateInventoryItemWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMachineWithOwner(),
                    
                
                    
                        
                        await associateMachineWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOrderWithOwner(),
                    
                
                    
                        
                        await associateProductionOrderWithDeal(),
                    
                
                    
                
                    
                        
                        await associateProductionOrderWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOperationWithProduction_order(),
                    
                
                    
                        
                        await associateProductionOperationWithMachine(),
                    
                
                    
                        
                        await associateProductionOperationWithAssigned_to(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOperationWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateQualityInspectionWithProduction_order(),
                    
                
                    
                        
                        await associateQualityInspectionWithOperation(),
                    
                
                    
                        
                        await associateQualityInspectionWithInspector(),
                    
                
                    
                
                    
                
                    
                        
                        await associateQualityInspectionWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithInspection(),
                    
                
                    
                        
                        await associateNonconformanceWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateVendorWithOwner(),
                    
                
                    
                
                    
                        
                        await associateVendorWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateVenueWithPreferred_vendor(),
                    
                
                    
                
                    
                        
                        await associateVenueWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventWithVenue(),
                    
                
                    
                        
                        await associateEventWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventTaskWithEvent(),
                    
                
                    
                        
                        await associateEventTaskWithAssigned_to(),
                    
                
                    
                        
                        await associateEventTaskWithVendor(),
                    
                
                    
                
                    
                
                    
                        
                        await associateEventTaskWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventGuestWithEvent(),
                    
                
                    
                
                    
                        
                        await associateEventGuestWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventScheduleItemWithEvent(),
                    
                
                    
                        
                        await associateEventScheduleItemWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateEventScheduleItemWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateBudgetItemWithEvent(),
                    
                
                    
                        
                        await associateBudgetItemWithVendor(),
                    
                
                    
                
                    
                
                    
                        
                        await associateBudgetItemWithOrganization(),
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('organizations', null, {});
            
            
            await queryInterface.bulkDelete('companies', null, {});
            
            
            await queryInterface.bulkDelete('contacts', null, {});
            
            
            await queryInterface.bulkDelete('pipelines', null, {});
            
            
            await queryInterface.bulkDelete('pipeline_stages', null, {});
            
            
            await queryInterface.bulkDelete('leads', null, {});
            
            
            await queryInterface.bulkDelete('deals', null, {});
            
            
            await queryInterface.bulkDelete('activities', null, {});
            
            
            await queryInterface.bulkDelete('materials', null, {});
            
            
            await queryInterface.bulkDelete('warehouses', null, {});
            
            
            await queryInterface.bulkDelete('inventory_items', null, {});
            
            
            await queryInterface.bulkDelete('machines', null, {});
            
            
            await queryInterface.bulkDelete('production_orders', null, {});
            
            
            await queryInterface.bulkDelete('production_operations', null, {});
            
            
            await queryInterface.bulkDelete('quality_inspections', null, {});
            
            
            await queryInterface.bulkDelete('nonconformances', null, {});
            
            
            await queryInterface.bulkDelete('vendors', null, {});
            
            
            await queryInterface.bulkDelete('venues', null, {});
            
            
            await queryInterface.bulkDelete('events', null, {});
            
            
            await queryInterface.bulkDelete('event_tasks', null, {});
            
            
            await queryInterface.bulkDelete('event_guests', null, {});
            
            
            await queryInterface.bulkDelete('event_schedule_items', null, {});
            
            
            await queryInterface.bulkDelete('budget_items', null, {});
            
        
    },
};