





















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






const Organizations = db.organizations;

const Tenants = db.tenants;

const Farms = db.farms;

const Trials = db.trials;

const TrialSites = db.trial_sites;

const Varieties = db.varieties;

const TrialEntries = db.trial_entries;

const Plots = db.plots;

const Plants = db.plants;

const ObservationEvents = db.observation_events;

const Traits = db.traits;

const Observations = db.observations;

const MediaAssets = db.media_assets;

const ReportTemplates = db.report_templates;

const Reports = db.reports;

const ApiClients = db.api_clients;







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



const TenantsData = [
    
    {
    
        
        
            
                "name": "Suncrest Breeding Co.",
            
        
    
        
        
            
                "code": "SUNCREST",
            
        
    
        
        
            
                "billing_email": "billing@suncrestbreeding.com",
            
        
    
        
        
            
                "farm_quota": 5,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "NorthRiver Genetics",
            
        
    
        
        
            
                "code": "NORTHRIVER",
            
        
    
        
        
            
                "billing_email": "finance@northrivergenetics.com",
            
        
    
        
        
            
                "farm_quota": 3,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "BlueOak Seed Labs",
            
        
    
        
        
            
                "code": "BLUEOAK",
            
        
    
        
        
            
                "billing_email": "accounts@blueoakseed.com",
            
        
    
        
        
            
                "farm_quota": 2,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Crescent Valley Horticulture",
            
        
    
        
        
            
                "code": "CRESCENT",
            
        
    
        
        
            
                "billing_email": "billing@crescentvalleyhort.com",
            
        
    
        
        
            
                "farm_quota": 4,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Everlight Breeding Group",
            
        
    
        
        
            
                "code": "EVERLIGHT",
            
        
    
        
        
            
                "billing_email": "billing@everlightbreeding.com",
            
        
    
        
        
            
                "farm_quota": 6,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const FarmsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Suncrest Farm - East Greenhouses",
            
        
    
        
        
            
                "code": "SFEG",
            
        
    
        
        
            
                "address": "1200 Orchard Rd, Salem, OR 97301, USA",
            
        
    
        
        
            
                "country": "USA",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "latitude": 44.9429,
            
        
    
        
        
            
                "longitude": -123.0351,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Green Valley Farm - Trial Range",
            
        
    
        
        
            
                "code": "GVTR",
            
        
    
        
        
            
                "address": "88 Riverbend Ave, Fresno, CA 93722, USA",
            
        
    
        
        
            
                "country": "USA",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "latitude": 36.7394,
            
        
    
        
        
            
                "longitude": -119.7856,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "NorthRiver Station - Research Glasshouse",
            
        
    
        
        
            
                "code": "NRRG",
            
        
    
        
        
            
                "address": "45 Innovation Dr, Boise, ID 83702, USA",
            
        
    
        
        
            
                "country": "USA",
            
        
    
        
        
            
                "timezone": "America/Boise",
            
        
    
        
        
            
                "latitude": 43.615,
            
        
    
        
        
            
                "longitude": -116.2023,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Suncrest Farm - West Blocks",
            
        
    
        
        
            
                "code": "SFWB",
            
        
    
        
        
            
                "address": "3050 Vineyard Ln, Eugene, OR 97401, USA",
            
        
    
        
        
            
                "country": "USA",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "latitude": 44.0521,
            
        
    
        
        
            
                "longitude": -123.0868,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "NorthRiver Field Annex",
            
        
    
        
        
            
                "code": "NRFA",
            
        
    
        
        
            
                "address": "2100 Meadow St, Meridian, ID 83642, USA",
            
        
    
        
        
            
                "country": "USA",
            
        
    
        
        
            
                "timezone": "America/Boise",
            
        
    
        
        
            
                "latitude": 43.6121,
            
        
    
        
        
            
                "longitude": -116.3915,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TrialsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Tomato Heat Tolerance Q2 2026",
            
        
    
        
        
            
                "code": "THT-2026-Q2",
            
        
    
        
        
            
                "objective": "Evaluate heat tolerance and fruit set across advanced tomato lines under elevated day temperatures.",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "planned_start_at": new Date('2026-04-01T08:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-06-30T18:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-04-03T08:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-06-28T18:00:00Z'),
            
        
    
        
        
            
                "protocol_notes": "Maintain daytime setpoint 32C for treatment bays; standard nutrition across all bays.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Cucumber Powdery Mildew Screen 2026",
            
        
    
        
        
            
                "code": "CPM-2026",
            
        
    
        
        
            
                "objective": "Screen cucumber varieties for powdery mildew resistance under high humidity cycles.",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "planned_start_at": new Date('2026-03-15T08:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-05-15T18:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-03-16T08:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-05-14T18:00:00Z'),
            
        
    
        
        
            
                "protocol_notes": "Inoculation at week 3; score weekly using 0-5 scale.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Lettuce Shelf Life Postharvest 2026",
            
        
    
        
        
            
                "code": "LSL-2026",
            
        
    
        
        
            
                "objective": "Compare postharvest shelf life and discoloration rates among romaine lines.",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "planned_start_at": new Date('2026-01-20T08:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-03-20T18:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-01-22T08:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-03-19T18:00:00Z'),
            
        
    
        
        
            
                "protocol_notes": "Harvest at uniform maturity; store at 4C; evaluate day 0, 7, 14.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Pepper Yield and Brix Summer 2026",
            
        
    
        
        
            
                "code": "PYB-2026",
            
        
    
        
        
            
                "objective": "Assess yield, fruit size, and soluble solids for sweet pepper candidates.",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "planned_start_at": new Date('2026-06-01T08:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-09-15T18:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-06-05T08:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-09-12T18:00:00Z'),
            
        
    
        
        
            
                "protocol_notes": "Weekly harvest weights per plot; brix measured from composite sample.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Basil Uniformity Trial 2026",
            
        
    
        
        
            
                "code": "BASIL-UNI-2026",
            
        
    
        
        
            
                "objective": "Quantify canopy uniformity and vigor under standard greenhouse conditions.",
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "planned_start_at": new Date('2025-11-01T08:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-01-10T18:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2025-11-03T08:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-01-08T18:00:00Z'),
            
        
    
        
        
            
                "protocol_notes": "Uniform irrigation schedule; measure height and fresh weight at harvest.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TrialSitesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Bay A - High Heat",
            
        
    
        
        
            
                "greenhouse_block": "East House A",
            
        
    
        
        
            
                "location_notes": "Heaters calibrated; CO2 supplementation active.",
            
        
    
        
        
            
                "rows_count": 10,
            
        
    
        
        
            
                "columns_count": 12,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Bay B - Control",
            
        
    
        
        
            
                "greenhouse_block": "East House B",
            
        
    
        
        
            
                "location_notes": "Standard setpoints; monitor vents weekly.",
            
        
    
        
        
            
                "rows_count": 10,
            
        
    
        
        
            
                "columns_count": 12,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "House 3 - Humidity Cycle",
            
        
    
        
        
            
                "greenhouse_block": "GV House 3",
            
        
    
        
        
            
                "location_notes": "Fogging system programmed for 75-85% RH cycles.",
            
        
    
        
        
            
                "rows_count": 8,
            
        
    
        
        
            
                "columns_count": 10,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Glasshouse 1 - Cold Room Access",
            
        
    
        
        
            
                "greenhouse_block": "NR Glasshouse 1",
            
        
    
        
        
            
                "location_notes": "Harvest staging adjacent to cold room door 2.",
            
        
    
        
        
            
                "rows_count": 6,
            
        
    
        
        
            
                "columns_count": 12,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Bay C - Summer Light",
            
        
    
        
        
            
                "greenhouse_block": "East House C",
            
        
    
        
        
            
                "location_notes": "Shade cloth available; deploy above 900 W/m2.",
            
        
    
        
        
            
                "rows_count": 12,
            
        
    
        
        
            
                "columns_count": 12,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const VarietiesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Solara T12",
            
        
    
        
        
            
                "variety_code": "SOL-T12",
            
        
    
        
        
            
                "species": "Tomato",
            
        
    
        
        
            
                "breeding_program": "Heat Tolerance",
            
        
    
        
        
            
                "notes": "Advanced line selected for fruit set under heat spikes.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Solara C7",
            
        
    
        
        
            
                "variety_code": "SOL-C7",
            
        
    
        
        
            
                "species": "Tomato",
            
        
    
        
        
            
                "breeding_program": "Core Elite",
            
        
    
        
        
            
                "notes": "Control line with stable yield performance.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "CrispCuke R3",
            
        
    
        
        
            
                "variety_code": "CCK-R3",
            
        
    
        
        
            
                "species": "Cucumber",
            
        
    
        
        
            
                "breeding_program": "Disease Resistance",
            
        
    
        
        
            
                "notes": "Candidate line with reported mildew tolerance.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Romaine NR-14",
            
        
    
        
        
            
                "variety_code": "ROM-NR14",
            
        
    
        
        
            
                "species": "Lettuce",
            
        
    
        
        
            
                "breeding_program": "Shelf Life",
            
        
    
        
        
            
                "notes": "Line selected for slow browning traits.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Genovese BL-2",
            
        
    
        
        
            
                "variety_code": "BAS-BL2",
            
        
    
        
        
            
                "species": "Basil",
            
        
    
        
        
            
                "breeding_program": "Uniformity",
            
        
    
        
        
            
                "notes": "Compact habit with uniform canopy across benches.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TrialEntriesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_label": "T12 Test",
            
        
    
        
        
            
                "entry_type": "standard_check",
            
        
    
        
        
            
                "treatment": "High heat",
            
        
    
        
        
            
                "notes": "Primary candidate under heat treatment.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_label": "C7 Control",
            
        
    
        
        
            
                "entry_type": "test",
            
        
    
        
        
            
                "treatment": "Control",
            
        
    
        
        
            
                "notes": "Baseline performance for comparison.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_label": "T12 Control",
            
        
    
        
        
            
                "entry_type": "test",
            
        
    
        
        
            
                "treatment": "Control",
            
        
    
        
        
            
                "notes": "Candidate grown under control setpoints.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_label": "C7 Heat",
            
        
    
        
        
            
                "entry_type": "control",
            
        
    
        
        
            
                "treatment": "High heat",
            
        
    
        
        
            
                "notes": "Control exposed to heat treatment for reference.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_label": "C7 Standard",
            
        
    
        
        
            
                "entry_type": "test",
            
        
    
        
        
            
                "treatment": "Standard nutrition",
            
        
    
        
        
            
                "notes": "Standard check across bays.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PlotsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plot_code": "A-R1-C1",
            
        
    
        
        
            
                "row_number": 1,
            
        
    
        
        
            
                "column_number": 1,
            
        
    
        
        
            
                "area_sq_m": 2.4,
            
        
    
        
        
            
                "target_plant_count": 12,
            
        
    
        
        
            
                "notes": "Corner bench near sensor mast.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plot_code": "A-R1-C2",
            
        
    
        
        
            
                "row_number": 1,
            
        
    
        
        
            
                "column_number": 2,
            
        
    
        
        
            
                "area_sq_m": 2.4,
            
        
    
        
        
            
                "target_plant_count": 12,
            
        
    
        
        
            
                "notes": "Ensure drip line pressure consistent.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plot_code": "B-R1-C1",
            
        
    
        
        
            
                "row_number": 1,
            
        
    
        
        
            
                "column_number": 1,
            
        
    
        
        
            
                "area_sq_m": 2.4,
            
        
    
        
        
            
                "target_plant_count": 12,
            
        
    
        
        
            
                "notes": "Control bay reference plot.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plot_code": "H3-R2-C4",
            
        
    
        
        
            
                "row_number": 2,
            
        
    
        
        
            
                "column_number": 4,
            
        
    
        
        
            
                "area_sq_m": 2.0,
            
        
    
        
        
            
                "target_plant_count": 10,
            
        
    
        
        
            
                "notes": "High humidity zone near fogger.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plot_code": "G1-R3-C6",
            
        
    
        
        
            
                "row_number": 3,
            
        
    
        
        
            
                "column_number": 6,
            
        
    
        
        
            
                "area_sq_m": 1.8,
            
        
    
        
        
            
                "target_plant_count": 18,
            
        
    
        
        
            
                "notes": "Harvest access aisle adjacent.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PlantsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plant_tag": "A-R1-C1-P01",
            
        
    
        
        
            
                "planted_at": new Date('2026-04-03T10:00:00Z'),
            
        
    
        
        
            
                "plant_status": "stressed",
            
        
    
        
        
            
                "notes": "Uniform transplant size.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plant_tag": "A-R1-C1-P02",
            
        
    
        
        
            
                "planted_at": new Date('2026-04-03T10:00:00Z'),
            
        
    
        
        
            
                "plant_status": "removed",
            
        
    
        
        
            
                "notes": "Monitor for blossom drop.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plant_tag": "A-R1-C2-P01",
            
        
    
        
        
            
                "planted_at": new Date('2026-04-03T10:15:00Z'),
            
        
    
        
        
            
                "plant_status": "removed",
            
        
    
        
        
            
                "notes": "Leaf curl observed week 2.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plant_tag": "B-R1-C1-P01",
            
        
    
        
        
            
                "planted_at": new Date('2026-04-03T10:30:00Z'),
            
        
    
        
        
            
                "plant_status": "alive",
            
        
    
        
        
            
                "notes": "Vigorous early growth.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "plant_tag": "G1-R3-C6-P01",
            
        
    
        
        
            
                "planted_at": new Date('2026-01-22T09:00:00Z'),
            
        
    
        
        
            
                "plant_status": "stressed",
            
        
    
        
        
            
                "notes": "Removed due to mechanical damage.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ObservationEventsData = [
    
    {
    
        
        
            
                // 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
            
        
    
        
        
            
                "observed_at": new Date('2026-04-17T16:00:00Z'),
            
        
    
        
        
            
                "event_type": "application",
            
        
    
        
        
            
                "summary": "Week 2 growth check",
            
        
    
        
        
            
                "notes": "Recorded height and first flower count; photo captured for reference.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "observed_at": new Date('2026-04-24T16:30:00Z'),
            
        
    
        
        
            
                "event_type": "harvest",
            
        
    
        
        
            
                "summary": "Heat stress symptoms",
            
        
    
        
        
            
                "notes": "Leaf curl and slight wilting noted in afternoon; irrigated and logged canopy temp.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "observed_at": new Date('2026-04-08T15:00:00Z'),
            
        
    
        
        
            
                "event_type": "scouting",
            
        
    
        
        
            
                "summary": "Pre-inoculation scouting",
            
        
    
        
        
            
                "notes": "No visible mildew; baseline photos taken.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "observed_at": new Date('2026-02-20T14:00:00Z'),
            
        
    
        
        
            
                "event_type": "scouting",
            
        
    
        
        
            
                "summary": "Harvest and store day 0",
            
        
    
        
        
            
                "notes": "Harvested at target maturity; moved to cold room at 4C within 30 minutes.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" 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
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "observed_at": new Date('2026-05-08T16:00:00Z'),
            
        
    
        
        
            
                "event_type": "issue",
            
        
    
        
        
            
                "summary": "Fruit set assessment",
            
        
    
        
        
            
                "notes": "Counted set fruit clusters; noted uniformity across control bay.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TraitsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Plant Height",
            
        
    
        
        
            
                "code": "HEIGHT_CM",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "unit": "count",
            
        
    
        
        
            
                "aggregation": "none",
            
        
    
        
        
            
                "description": "Measured from substrate to apical meristem.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Flower Count",
            
        
    
        
        
            
                "code": "FLOWER_CT",
            
        
    
        
        
            
                "data_type": "boolean",
            
        
    
        
        
            
                "unit": "g",
            
        
    
        
        
            
                "aggregation": "avg",
            
        
    
        
        
            
                "description": "Total open flowers at observation time.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Mildew Severity",
            
        
    
        
        
            
                "code": "PM_SEV",
            
        
    
        
        
            
                "data_type": "decimal",
            
        
    
        
        
            
                "unit": "cm",
            
        
    
        
        
            
                "aggregation": "none",
            
        
    
        
        
            
                "description": "0-5 visual score for powdery mildew severity.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Browning Score",
            
        
    
        
        
            
                "code": "BROWN_0_5",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "unit": "celsius",
            
        
    
        
        
            
                "aggregation": "min",
            
        
    
        
        
            
                "description": "Discoloration score 0-5 after storage.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Canopy Temperature",
            
        
    
        
        
            
                "code": "CANOPY_C",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "unit": "fahrenheit",
            
        
    
        
        
            
                "aggregation": "avg",
            
        
    
        
        
            
                "description": "Infrared canopy temperature at midday.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ObservationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "value_decimal": 32.6,
            
        
    
        
        
            
                "value_int": 7,
            
        
    
        
        
            
                "value_boolean": false,
            
        
    
        
        
            
                "value_text": "32.6",
            
        
    
        
        
            
                "value_enum": "low",
            
        
    
        
        
            
                "quality_flag": "invalid",
            
        
    
        
        
            
                "comment": "Average of 3 readings.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "value_decimal": 1.18,
            
        
    
        
        
            
                "value_int": 6,
            
        
    
        
        
            
                "value_boolean": true,
            
        
    
        
        
            
                "value_text": "6",
            
        
    
        
        
            
                "value_enum": "na",
            
        
    
        
        
            
                "quality_flag": "invalid",
            
        
    
        
        
            
                "comment": "Counted open flowers.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "value_decimal": 35.9,
            
        
    
        
        
            
                "value_int": 1,
            
        
    
        
        
            
                "value_boolean": false,
            
        
    
        
        
            
                "value_text": "35.9",
            
        
    
        
        
            
                "value_enum": "medium",
            
        
    
        
        
            
                "quality_flag": "ok",
            
        
    
        
        
            
                "comment": "Sensor briefly shaded; verify next visit.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "value_decimal": 5.94,
            
        
    
        
        
            
                "value_int": 9,
            
        
    
        
        
            
                "value_boolean": true,
            
        
    
        
        
            
                "value_text": "Baseline 0",
            
        
    
        
        
            
                "value_enum": "low",
            
        
    
        
        
            
                "quality_flag": "ok",
            
        
    
        
        
            
                "comment": "No lesions visible pre-inoculation.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "value_decimal": 5.23,
            
        
    
        
        
            
                "value_int": 1,
            
        
    
        
        
            
                "value_boolean": false,
            
        
    
        
        
            
                "value_text": "1",
            
        
    
        
        
            
                "value_enum": "high",
            
        
    
        
        
            
                "quality_flag": "invalid",
            
        
    
        
        
            
                "comment": "Day 0 browning minimal.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const MediaAssetsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "media_type": "image",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "caption": "Plot A-R1-C1 week 2 canopy",
            
        
    
        
        
            
                "tags": "tomato,canopy,week2",
            
        
    
        
        
            
                "captured_at": new Date('2026-04-17T16:05:00Z'),
            
        
    
        
        
            
                "source": "mobile",
            
        
    
        
        
            
                "is_private": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "media_type": "image",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "caption": "Leaf curl under heat treatment",
            
        
    
        
        
            
                "tags": "tomato,heat,stress",
            
        
    
        
        
            
                "captured_at": new Date('2026-04-24T16:35:00Z'),
            
        
    
        
        
            
                "source": "mobile",
            
        
    
        
        
            
                "is_private": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "media_type": "image",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "caption": "House 3 baseline foliage",
            
        
    
        
        
            
                "tags": "cucumber,baseline",
            
        
    
        
        
            
                "captured_at": new Date('2026-04-08T15:05:00Z'),
            
        
    
        
        
            
                "source": "mobile",
            
        
    
        
        
            
                "is_private": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "media_type": "video",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "caption": "Harvest checklist day 0",
            
        
    
        
        
            
                "tags": "lettuce,harvest,checklist",
            
        
    
        
        
            
                "captured_at": new Date('2026-02-20T14:10:00Z'),
            
        
    
        
        
            
                "source": "web",
            
        
    
        
        
            
                "is_private": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "media_type": "video",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "caption": "Control bay fruit set walkthrough",
            
        
    
        
        
            
                "tags": "tomato,fruitset,video",
            
        
    
        
        
            
                "captured_at": new Date('2026-05-08T16:10:00Z'),
            
        
    
        
        
            
                "source": "mobile",
            
        
    
        
        
            
                "is_private": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ReportTemplatesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Trial Summary PDF",
            
        
    
        
        
            
                "format": "html",
            
        
    
        
        
            
                "description": "Standard trial summary with KPIs, charts, and selected photos.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Observation Export XLSX",
            
        
    
        
        
            
                "format": "xlsx",
            
        
    
        
        
            
                "description": "Flat export of observation events and trait values for analysis.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Postharvest Scorecard PDF",
            
        
    
        
        
            
                "format": "xlsx",
            
        
    
        
        
            
                "description": "Scorecard for day 0/7/14 assessments with notes and images.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Media Appendix PDF",
            
        
    
        
        
            
                "format": "pdf",
            
        
    
        
        
            
                "description": "Photo and video index appendix grouped by site and date.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "KPI Dashboard HTML",
            
        
    
        
        
            
                "format": "pdf",
            
        
    
        
        
            
                "description": "HTML report for quick sharing of key metrics and trends.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ReportsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "THT-2026-Q2 Interim Summary - May",
            
        
    
        
        
            
                "status": "queued",
            
        
    
        
        
            
                "generated_at": new Date('2026-05-10T09:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Includes week 2-5 measurements and representative photos.",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "name": "THT-2026-Q2 Observations Export - Week 5",
            
        
    
        
        
            
                "status": "running",
            
        
    
        
        
            
                "generated_at": new Date('2026-05-09T18:30:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Export used for internal analysis in R.",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "name": "CPM-2026 Setup Pack",
            
        
    
        
        
            
                "status": "ready",
            
        
    
        
        
            
                "generated_at": new Date('2026-03-14T12:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Trial setup checklist and initial map.",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "name": "LSL-2026 Day 0 Scorecard",
            
        
    
        
        
            
                "status": "queued",
            
        
    
        
        
            
                "generated_at": new Date('2026-02-20T18:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Initial postharvest condition documented.",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "name": "PYB-2026 Draft Export",
            
        
    
        
        
            
                "status": "ready",
            
        
    
        
        
            
                "generated_at": new Date('2026-06-06T08:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Failed due to missing trait mappings; update template configuration.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ApiClientsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Suncrest Mobile iOS",
            
        
    
        
        
            
                "client_type": "integration",
            
        
    
        
        
            
                "client_key": "sc_suncrest_ios_2026_01",
            
        
    
        
        
            
                "scopes": "trials:read observations:write media:write reports:read",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "last_used_at": new Date('2026-05-08T16:12:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Suncrest PowerBI Connector",
            
        
    
        
        
            
                "client_type": "integration",
            
        
    
        
        
            
                "client_key": "sc_suncrest_bi_2026_02",
            
        
    
        
        
            
                "scopes": "reports:read observations:read trials:read",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "last_used_at": new Date('2026-05-10T09:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "NorthRiver Mobile Android",
            
        
    
        
        
            
                "client_type": "integration",
            
        
    
        
        
            
                "client_key": "nr_android_2026_01",
            
        
    
        
        
            
                "scopes": "trials:read observations:write media:write",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "last_used_at": new Date('2026-02-20T14:12:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "NorthRiver Lab Importer",
            
        
    
        
        
            
                "client_type": "internal_tool",
            
        
    
        
        
            
                "client_key": "nr_lab_import_2026_03",
            
        
    
        
        
            
                "scopes": "traits:read observations:write",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "last_used_at": new Date('2026-03-01T11:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Internal QA Client",
            
        
    
        
        
            
                "client_type": "internal_tool",
            
        
    
        
        
            
                "client_key": "tt_internal_qa_2026_04",
            
        
    
        
        
            
                "scopes": "users:read trials:read observations:read",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "last_used_at": new Date('2026-05-01T10:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];




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

    
    
    
    
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            
            async function associateTenantWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Tenant0 = await Tenants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Tenant0?.setOrganization)
                {
                    await
                    Tenant0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Tenant1 = await Tenants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Tenant1?.setOrganization)
                {
                    await
                    Tenant1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Tenant2 = await Tenants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Tenant2?.setOrganization)
                {
                    await
                    Tenant2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Tenant3 = await Tenants.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Tenant3?.setOrganization)
                {
                    await
                    Tenant3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Tenant4 = await Tenants.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Tenant4?.setOrganization)
                {
                    await
                    Tenant4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateFarmWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Farm0 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Farm0?.setTenant)
                {
                    await
                    Farm0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Farm1 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Farm1?.setTenant)
                {
                    await
                    Farm1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Farm2 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Farm2?.setTenant)
                {
                    await
                    Farm2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Farm3 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Farm3?.setTenant)
                {
                    await
                    Farm3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Farm4 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Farm4?.setTenant)
                {
                    await
                    Farm4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateFarmWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Farm0 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Farm0?.setOrganization)
                {
                    await
                    Farm0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Farm1 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Farm1?.setOrganization)
                {
                    await
                    Farm1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Farm2 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Farm2?.setOrganization)
                {
                    await
                    Farm2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Farm3 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Farm3?.setOrganization)
                {
                    await
                    Farm3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Farm4 = await Farms.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Farm4?.setOrganization)
                {
                    await
                    Farm4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTrialWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trial0 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Trial0?.setTenant)
                {
                    await
                    Trial0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trial1 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Trial1?.setTenant)
                {
                    await
                    Trial1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trial2 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Trial2?.setTenant)
                {
                    await
                    Trial2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trial3 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Trial3?.setTenant)
                {
                    await
                    Trial3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trial4 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Trial4?.setTenant)
                {
                    await
                    Trial4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
            
            async function associateTrialWithFarm() {
            
                const relatedFarm0 = await Farms.findOne({
                    offset: Math.floor(Math.random() * (await Farms.count())),
                });
                const Trial0 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Trial0?.setFarm)
                {
                    await
                    Trial0.
                    setFarm(relatedFarm0);
                }
            
                const relatedFarm1 = await Farms.findOne({
                    offset: Math.floor(Math.random() * (await Farms.count())),
                });
                const Trial1 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Trial1?.setFarm)
                {
                    await
                    Trial1.
                    setFarm(relatedFarm1);
                }
            
                const relatedFarm2 = await Farms.findOne({
                    offset: Math.floor(Math.random() * (await Farms.count())),
                });
                const Trial2 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Trial2?.setFarm)
                {
                    await
                    Trial2.
                    setFarm(relatedFarm2);
                }
            
                const relatedFarm3 = await Farms.findOne({
                    offset: Math.floor(Math.random() * (await Farms.count())),
                });
                const Trial3 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Trial3?.setFarm)
                {
                    await
                    Trial3.
                    setFarm(relatedFarm3);
                }
            
                const relatedFarm4 = await Farms.findOne({
                    offset: Math.floor(Math.random() * (await Farms.count())),
                });
                const Trial4 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Trial4?.setFarm)
                {
                    await
                    Trial4.
                    setFarm(relatedFarm4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            // Similar logic for "relation_many"
        
    
        
            
            async function associateTrialWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trial0 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Trial0?.setOrganization)
                {
                    await
                    Trial0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trial1 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Trial1?.setOrganization)
                {
                    await
                    Trial1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trial2 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Trial2?.setOrganization)
                {
                    await
                    Trial2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trial3 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Trial3?.setOrganization)
                {
                    await
                    Trial3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trial4 = await Trials.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Trial4?.setOrganization)
                {
                    await
                    Trial4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTrialSiteWithTrial() {
            
                const relatedTrial0 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialSite0 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrialSite0?.setTrial)
                {
                    await
                    TrialSite0.
                    setTrial(relatedTrial0);
                }
            
                const relatedTrial1 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialSite1 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrialSite1?.setTrial)
                {
                    await
                    TrialSite1.
                    setTrial(relatedTrial1);
                }
            
                const relatedTrial2 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialSite2 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrialSite2?.setTrial)
                {
                    await
                    TrialSite2.
                    setTrial(relatedTrial2);
                }
            
                const relatedTrial3 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialSite3 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrialSite3?.setTrial)
                {
                    await
                    TrialSite3.
                    setTrial(relatedTrial3);
                }
            
                const relatedTrial4 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialSite4 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrialSite4?.setTrial)
                {
                    await
                    TrialSite4.
                    setTrial(relatedTrial4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTrialSiteWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialSite0 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrialSite0?.setOrganization)
                {
                    await
                    TrialSite0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialSite1 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrialSite1?.setOrganization)
                {
                    await
                    TrialSite1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialSite2 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrialSite2?.setOrganization)
                {
                    await
                    TrialSite2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialSite3 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrialSite3?.setOrganization)
                {
                    await
                    TrialSite3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialSite4 = await TrialSites.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrialSite4?.setOrganization)
                {
                    await
                    TrialSite4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateVarietyWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Variety0 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Variety0?.setTenant)
                {
                    await
                    Variety0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Variety1 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Variety1?.setTenant)
                {
                    await
                    Variety1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Variety2 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Variety2?.setTenant)
                {
                    await
                    Variety2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Variety3 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Variety3?.setTenant)
                {
                    await
                    Variety3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Variety4 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Variety4?.setTenant)
                {
                    await
                    Variety4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateVarietyWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Variety0 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Variety0?.setOrganization)
                {
                    await
                    Variety0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Variety1 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Variety1?.setOrganization)
                {
                    await
                    Variety1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Variety2 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Variety2?.setOrganization)
                {
                    await
                    Variety2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Variety3 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Variety3?.setOrganization)
                {
                    await
                    Variety3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Variety4 = await Varieties.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Variety4?.setOrganization)
                {
                    await
                    Variety4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTrialEntryWithTrial() {
            
                const relatedTrial0 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialEntry0 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrialEntry0?.setTrial)
                {
                    await
                    TrialEntry0.
                    setTrial(relatedTrial0);
                }
            
                const relatedTrial1 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialEntry1 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrialEntry1?.setTrial)
                {
                    await
                    TrialEntry1.
                    setTrial(relatedTrial1);
                }
            
                const relatedTrial2 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialEntry2 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrialEntry2?.setTrial)
                {
                    await
                    TrialEntry2.
                    setTrial(relatedTrial2);
                }
            
                const relatedTrial3 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialEntry3 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrialEntry3?.setTrial)
                {
                    await
                    TrialEntry3.
                    setTrial(relatedTrial3);
                }
            
                const relatedTrial4 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const TrialEntry4 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrialEntry4?.setTrial)
                {
                    await
                    TrialEntry4.
                    setTrial(relatedTrial4);
                }
            
        }
        
    
        
            
            async function associateTrialEntryWithVariety() {
            
                const relatedVariety0 = await Varieties.findOne({
                    offset: Math.floor(Math.random() * (await Varieties.count())),
                });
                const TrialEntry0 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrialEntry0?.setVariety)
                {
                    await
                    TrialEntry0.
                    setVariety(relatedVariety0);
                }
            
                const relatedVariety1 = await Varieties.findOne({
                    offset: Math.floor(Math.random() * (await Varieties.count())),
                });
                const TrialEntry1 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrialEntry1?.setVariety)
                {
                    await
                    TrialEntry1.
                    setVariety(relatedVariety1);
                }
            
                const relatedVariety2 = await Varieties.findOne({
                    offset: Math.floor(Math.random() * (await Varieties.count())),
                });
                const TrialEntry2 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrialEntry2?.setVariety)
                {
                    await
                    TrialEntry2.
                    setVariety(relatedVariety2);
                }
            
                const relatedVariety3 = await Varieties.findOne({
                    offset: Math.floor(Math.random() * (await Varieties.count())),
                });
                const TrialEntry3 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrialEntry3?.setVariety)
                {
                    await
                    TrialEntry3.
                    setVariety(relatedVariety3);
                }
            
                const relatedVariety4 = await Varieties.findOne({
                    offset: Math.floor(Math.random() * (await Varieties.count())),
                });
                const TrialEntry4 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrialEntry4?.setVariety)
                {
                    await
                    TrialEntry4.
                    setVariety(relatedVariety4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTrialEntryWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialEntry0 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrialEntry0?.setOrganization)
                {
                    await
                    TrialEntry0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialEntry1 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrialEntry1?.setOrganization)
                {
                    await
                    TrialEntry1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialEntry2 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrialEntry2?.setOrganization)
                {
                    await
                    TrialEntry2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialEntry3 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrialEntry3?.setOrganization)
                {
                    await
                    TrialEntry3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TrialEntry4 = await TrialEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrialEntry4?.setOrganization)
                {
                    await
                    TrialEntry4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePlotWithTrial_site() {
            
                const relatedTrial_site0 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const Plot0 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Plot0?.setTrial_site)
                {
                    await
                    Plot0.
                    setTrial_site(relatedTrial_site0);
                }
            
                const relatedTrial_site1 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const Plot1 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Plot1?.setTrial_site)
                {
                    await
                    Plot1.
                    setTrial_site(relatedTrial_site1);
                }
            
                const relatedTrial_site2 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const Plot2 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Plot2?.setTrial_site)
                {
                    await
                    Plot2.
                    setTrial_site(relatedTrial_site2);
                }
            
                const relatedTrial_site3 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const Plot3 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Plot3?.setTrial_site)
                {
                    await
                    Plot3.
                    setTrial_site(relatedTrial_site3);
                }
            
                const relatedTrial_site4 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const Plot4 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Plot4?.setTrial_site)
                {
                    await
                    Plot4.
                    setTrial_site(relatedTrial_site4);
                }
            
        }
        
    
        
            
            async function associatePlotWithTrial_entry() {
            
                const relatedTrial_entry0 = await TrialEntries.findOne({
                    offset: Math.floor(Math.random() * (await TrialEntries.count())),
                });
                const Plot0 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Plot0?.setTrial_entry)
                {
                    await
                    Plot0.
                    setTrial_entry(relatedTrial_entry0);
                }
            
                const relatedTrial_entry1 = await TrialEntries.findOne({
                    offset: Math.floor(Math.random() * (await TrialEntries.count())),
                });
                const Plot1 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Plot1?.setTrial_entry)
                {
                    await
                    Plot1.
                    setTrial_entry(relatedTrial_entry1);
                }
            
                const relatedTrial_entry2 = await TrialEntries.findOne({
                    offset: Math.floor(Math.random() * (await TrialEntries.count())),
                });
                const Plot2 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Plot2?.setTrial_entry)
                {
                    await
                    Plot2.
                    setTrial_entry(relatedTrial_entry2);
                }
            
                const relatedTrial_entry3 = await TrialEntries.findOne({
                    offset: Math.floor(Math.random() * (await TrialEntries.count())),
                });
                const Plot3 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Plot3?.setTrial_entry)
                {
                    await
                    Plot3.
                    setTrial_entry(relatedTrial_entry3);
                }
            
                const relatedTrial_entry4 = await TrialEntries.findOne({
                    offset: Math.floor(Math.random() * (await TrialEntries.count())),
                });
                const Plot4 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Plot4?.setTrial_entry)
                {
                    await
                    Plot4.
                    setTrial_entry(relatedTrial_entry4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePlotWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plot0 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Plot0?.setOrganization)
                {
                    await
                    Plot0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plot1 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Plot1?.setOrganization)
                {
                    await
                    Plot1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plot2 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Plot2?.setOrganization)
                {
                    await
                    Plot2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plot3 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Plot3?.setOrganization)
                {
                    await
                    Plot3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plot4 = await Plots.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Plot4?.setOrganization)
                {
                    await
                    Plot4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePlantWithPlot() {
            
                const relatedPlot0 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const Plant0 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Plant0?.setPlot)
                {
                    await
                    Plant0.
                    setPlot(relatedPlot0);
                }
            
                const relatedPlot1 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const Plant1 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Plant1?.setPlot)
                {
                    await
                    Plant1.
                    setPlot(relatedPlot1);
                }
            
                const relatedPlot2 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const Plant2 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Plant2?.setPlot)
                {
                    await
                    Plant2.
                    setPlot(relatedPlot2);
                }
            
                const relatedPlot3 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const Plant3 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Plant3?.setPlot)
                {
                    await
                    Plant3.
                    setPlot(relatedPlot3);
                }
            
                const relatedPlot4 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const Plant4 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Plant4?.setPlot)
                {
                    await
                    Plant4.
                    setPlot(relatedPlot4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePlantWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plant0 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Plant0?.setOrganization)
                {
                    await
                    Plant0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plant1 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Plant1?.setOrganization)
                {
                    await
                    Plant1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plant2 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Plant2?.setOrganization)
                {
                    await
                    Plant2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plant3 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Plant3?.setOrganization)
                {
                    await
                    Plant3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Plant4 = await Plants.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Plant4?.setOrganization)
                {
                    await
                    Plant4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateObservationEventWithTrial() {
            
                const relatedTrial0 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setTrial)
                {
                    await
                    ObservationEvent0.
                    setTrial(relatedTrial0);
                }
            
                const relatedTrial1 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setTrial)
                {
                    await
                    ObservationEvent1.
                    setTrial(relatedTrial1);
                }
            
                const relatedTrial2 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setTrial)
                {
                    await
                    ObservationEvent2.
                    setTrial(relatedTrial2);
                }
            
                const relatedTrial3 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setTrial)
                {
                    await
                    ObservationEvent3.
                    setTrial(relatedTrial3);
                }
            
                const relatedTrial4 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setTrial)
                {
                    await
                    ObservationEvent4.
                    setTrial(relatedTrial4);
                }
            
        }
        
    
        
            
            async function associateObservationEventWithTrial_site() {
            
                const relatedTrial_site0 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setTrial_site)
                {
                    await
                    ObservationEvent0.
                    setTrial_site(relatedTrial_site0);
                }
            
                const relatedTrial_site1 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setTrial_site)
                {
                    await
                    ObservationEvent1.
                    setTrial_site(relatedTrial_site1);
                }
            
                const relatedTrial_site2 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setTrial_site)
                {
                    await
                    ObservationEvent2.
                    setTrial_site(relatedTrial_site2);
                }
            
                const relatedTrial_site3 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setTrial_site)
                {
                    await
                    ObservationEvent3.
                    setTrial_site(relatedTrial_site3);
                }
            
                const relatedTrial_site4 = await TrialSites.findOne({
                    offset: Math.floor(Math.random() * (await TrialSites.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setTrial_site)
                {
                    await
                    ObservationEvent4.
                    setTrial_site(relatedTrial_site4);
                }
            
        }
        
    
        
            
            async function associateObservationEventWithPlot() {
            
                const relatedPlot0 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setPlot)
                {
                    await
                    ObservationEvent0.
                    setPlot(relatedPlot0);
                }
            
                const relatedPlot1 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setPlot)
                {
                    await
                    ObservationEvent1.
                    setPlot(relatedPlot1);
                }
            
                const relatedPlot2 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setPlot)
                {
                    await
                    ObservationEvent2.
                    setPlot(relatedPlot2);
                }
            
                const relatedPlot3 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setPlot)
                {
                    await
                    ObservationEvent3.
                    setPlot(relatedPlot3);
                }
            
                const relatedPlot4 = await Plots.findOne({
                    offset: Math.floor(Math.random() * (await Plots.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setPlot)
                {
                    await
                    ObservationEvent4.
                    setPlot(relatedPlot4);
                }
            
        }
        
    
        
            
            async function associateObservationEventWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setPlant)
                {
                    await
                    ObservationEvent0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setPlant)
                {
                    await
                    ObservationEvent1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setPlant)
                {
                    await
                    ObservationEvent2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setPlant)
                {
                    await
                    ObservationEvent3.
                    setPlant(relatedPlant3);
                }
            
                const relatedPlant4 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setPlant)
                {
                    await
                    ObservationEvent4.
                    setPlant(relatedPlant4);
                }
            
        }
        
    
        
            
            async function associateObservationEventWithObserver() {
            
                const relatedObserver0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setObserver)
                {
                    await
                    ObservationEvent0.
                    setObserver(relatedObserver0);
                }
            
                const relatedObserver1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setObserver)
                {
                    await
                    ObservationEvent1.
                    setObserver(relatedObserver1);
                }
            
                const relatedObserver2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setObserver)
                {
                    await
                    ObservationEvent2.
                    setObserver(relatedObserver2);
                }
            
                const relatedObserver3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setObserver)
                {
                    await
                    ObservationEvent3.
                    setObserver(relatedObserver3);
                }
            
                const relatedObserver4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setObserver)
                {
                    await
                    ObservationEvent4.
                    setObserver(relatedObserver4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            // Similar logic for "relation_many"
        
    
        
            
            async function associateObservationEventWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ObservationEvent0 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ObservationEvent0?.setOrganization)
                {
                    await
                    ObservationEvent0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ObservationEvent1 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ObservationEvent1?.setOrganization)
                {
                    await
                    ObservationEvent1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ObservationEvent2 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ObservationEvent2?.setOrganization)
                {
                    await
                    ObservationEvent2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ObservationEvent3 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ObservationEvent3?.setOrganization)
                {
                    await
                    ObservationEvent3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ObservationEvent4 = await ObservationEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ObservationEvent4?.setOrganization)
                {
                    await
                    ObservationEvent4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTraitWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trait0 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Trait0?.setTenant)
                {
                    await
                    Trait0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trait1 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Trait1?.setTenant)
                {
                    await
                    Trait1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trait2 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Trait2?.setTenant)
                {
                    await
                    Trait2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trait3 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Trait3?.setTenant)
                {
                    await
                    Trait3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const Trait4 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Trait4?.setTenant)
                {
                    await
                    Trait4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTraitWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trait0 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Trait0?.setOrganization)
                {
                    await
                    Trait0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trait1 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Trait1?.setOrganization)
                {
                    await
                    Trait1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trait2 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Trait2?.setOrganization)
                {
                    await
                    Trait2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trait3 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Trait3?.setOrganization)
                {
                    await
                    Trait3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Trait4 = await Traits.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Trait4?.setOrganization)
                {
                    await
                    Trait4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateObservationWithObservation_event() {
            
                const relatedObservation_event0 = await ObservationEvents.findOne({
                    offset: Math.floor(Math.random() * (await ObservationEvents.count())),
                });
                const Observation0 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Observation0?.setObservation_event)
                {
                    await
                    Observation0.
                    setObservation_event(relatedObservation_event0);
                }
            
                const relatedObservation_event1 = await ObservationEvents.findOne({
                    offset: Math.floor(Math.random() * (await ObservationEvents.count())),
                });
                const Observation1 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Observation1?.setObservation_event)
                {
                    await
                    Observation1.
                    setObservation_event(relatedObservation_event1);
                }
            
                const relatedObservation_event2 = await ObservationEvents.findOne({
                    offset: Math.floor(Math.random() * (await ObservationEvents.count())),
                });
                const Observation2 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Observation2?.setObservation_event)
                {
                    await
                    Observation2.
                    setObservation_event(relatedObservation_event2);
                }
            
                const relatedObservation_event3 = await ObservationEvents.findOne({
                    offset: Math.floor(Math.random() * (await ObservationEvents.count())),
                });
                const Observation3 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Observation3?.setObservation_event)
                {
                    await
                    Observation3.
                    setObservation_event(relatedObservation_event3);
                }
            
                const relatedObservation_event4 = await ObservationEvents.findOne({
                    offset: Math.floor(Math.random() * (await ObservationEvents.count())),
                });
                const Observation4 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Observation4?.setObservation_event)
                {
                    await
                    Observation4.
                    setObservation_event(relatedObservation_event4);
                }
            
        }
        
    
        
            
            async function associateObservationWithTrait() {
            
                const relatedTrait0 = await Traits.findOne({
                    offset: Math.floor(Math.random() * (await Traits.count())),
                });
                const Observation0 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Observation0?.setTrait)
                {
                    await
                    Observation0.
                    setTrait(relatedTrait0);
                }
            
                const relatedTrait1 = await Traits.findOne({
                    offset: Math.floor(Math.random() * (await Traits.count())),
                });
                const Observation1 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Observation1?.setTrait)
                {
                    await
                    Observation1.
                    setTrait(relatedTrait1);
                }
            
                const relatedTrait2 = await Traits.findOne({
                    offset: Math.floor(Math.random() * (await Traits.count())),
                });
                const Observation2 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Observation2?.setTrait)
                {
                    await
                    Observation2.
                    setTrait(relatedTrait2);
                }
            
                const relatedTrait3 = await Traits.findOne({
                    offset: Math.floor(Math.random() * (await Traits.count())),
                });
                const Observation3 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Observation3?.setTrait)
                {
                    await
                    Observation3.
                    setTrait(relatedTrait3);
                }
            
                const relatedTrait4 = await Traits.findOne({
                    offset: Math.floor(Math.random() * (await Traits.count())),
                });
                const Observation4 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Observation4?.setTrait)
                {
                    await
                    Observation4.
                    setTrait(relatedTrait4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateObservationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Observation0 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Observation0?.setOrganization)
                {
                    await
                    Observation0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Observation1 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Observation1?.setOrganization)
                {
                    await
                    Observation1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Observation2 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Observation2?.setOrganization)
                {
                    await
                    Observation2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Observation3 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Observation3?.setOrganization)
                {
                    await
                    Observation3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Observation4 = await Observations.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Observation4?.setOrganization)
                {
                    await
                    Observation4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateMediaAssetWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const MediaAsset0 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MediaAsset0?.setTenant)
                {
                    await
                    MediaAsset0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const MediaAsset1 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MediaAsset1?.setTenant)
                {
                    await
                    MediaAsset1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const MediaAsset2 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MediaAsset2?.setTenant)
                {
                    await
                    MediaAsset2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const MediaAsset3 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (MediaAsset3?.setTenant)
                {
                    await
                    MediaAsset3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const MediaAsset4 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (MediaAsset4?.setTenant)
                {
                    await
                    MediaAsset4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
            
            async function associateMediaAssetWithUploaded_by() {
            
                const relatedUploaded_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MediaAsset0 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MediaAsset0?.setUploaded_by)
                {
                    await
                    MediaAsset0.
                    setUploaded_by(relatedUploaded_by0);
                }
            
                const relatedUploaded_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MediaAsset1 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MediaAsset1?.setUploaded_by)
                {
                    await
                    MediaAsset1.
                    setUploaded_by(relatedUploaded_by1);
                }
            
                const relatedUploaded_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MediaAsset2 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MediaAsset2?.setUploaded_by)
                {
                    await
                    MediaAsset2.
                    setUploaded_by(relatedUploaded_by2);
                }
            
                const relatedUploaded_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MediaAsset3 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (MediaAsset3?.setUploaded_by)
                {
                    await
                    MediaAsset3.
                    setUploaded_by(relatedUploaded_by3);
                }
            
                const relatedUploaded_by4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MediaAsset4 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (MediaAsset4?.setUploaded_by)
                {
                    await
                    MediaAsset4.
                    setUploaded_by(relatedUploaded_by4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMediaAssetWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const MediaAsset0 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MediaAsset0?.setOrganization)
                {
                    await
                    MediaAsset0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const MediaAsset1 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MediaAsset1?.setOrganization)
                {
                    await
                    MediaAsset1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const MediaAsset2 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MediaAsset2?.setOrganization)
                {
                    await
                    MediaAsset2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const MediaAsset3 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (MediaAsset3?.setOrganization)
                {
                    await
                    MediaAsset3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const MediaAsset4 = await MediaAssets.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (MediaAsset4?.setOrganization)
                {
                    await
                    MediaAsset4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateReportTemplateWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ReportTemplate0 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReportTemplate0?.setTenant)
                {
                    await
                    ReportTemplate0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ReportTemplate1 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReportTemplate1?.setTenant)
                {
                    await
                    ReportTemplate1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ReportTemplate2 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReportTemplate2?.setTenant)
                {
                    await
                    ReportTemplate2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ReportTemplate3 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReportTemplate3?.setTenant)
                {
                    await
                    ReportTemplate3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ReportTemplate4 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ReportTemplate4?.setTenant)
                {
                    await
                    ReportTemplate4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateReportTemplateWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReportTemplate0 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReportTemplate0?.setOrganization)
                {
                    await
                    ReportTemplate0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReportTemplate1 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReportTemplate1?.setOrganization)
                {
                    await
                    ReportTemplate1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReportTemplate2 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReportTemplate2?.setOrganization)
                {
                    await
                    ReportTemplate2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReportTemplate3 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReportTemplate3?.setOrganization)
                {
                    await
                    ReportTemplate3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReportTemplate4 = await ReportTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ReportTemplate4?.setOrganization)
                {
                    await
                    ReportTemplate4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateReportWithTrial() {
            
                const relatedTrial0 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const Report0 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Report0?.setTrial)
                {
                    await
                    Report0.
                    setTrial(relatedTrial0);
                }
            
                const relatedTrial1 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const Report1 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Report1?.setTrial)
                {
                    await
                    Report1.
                    setTrial(relatedTrial1);
                }
            
                const relatedTrial2 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const Report2 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Report2?.setTrial)
                {
                    await
                    Report2.
                    setTrial(relatedTrial2);
                }
            
                const relatedTrial3 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const Report3 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Report3?.setTrial)
                {
                    await
                    Report3.
                    setTrial(relatedTrial3);
                }
            
                const relatedTrial4 = await Trials.findOne({
                    offset: Math.floor(Math.random() * (await Trials.count())),
                });
                const Report4 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Report4?.setTrial)
                {
                    await
                    Report4.
                    setTrial(relatedTrial4);
                }
            
        }
        
    
        
            
            async function associateReportWithTemplate() {
            
                const relatedTemplate0 = await ReportTemplates.findOne({
                    offset: Math.floor(Math.random() * (await ReportTemplates.count())),
                });
                const Report0 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Report0?.setTemplate)
                {
                    await
                    Report0.
                    setTemplate(relatedTemplate0);
                }
            
                const relatedTemplate1 = await ReportTemplates.findOne({
                    offset: Math.floor(Math.random() * (await ReportTemplates.count())),
                });
                const Report1 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Report1?.setTemplate)
                {
                    await
                    Report1.
                    setTemplate(relatedTemplate1);
                }
            
                const relatedTemplate2 = await ReportTemplates.findOne({
                    offset: Math.floor(Math.random() * (await ReportTemplates.count())),
                });
                const Report2 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Report2?.setTemplate)
                {
                    await
                    Report2.
                    setTemplate(relatedTemplate2);
                }
            
                const relatedTemplate3 = await ReportTemplates.findOne({
                    offset: Math.floor(Math.random() * (await ReportTemplates.count())),
                });
                const Report3 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Report3?.setTemplate)
                {
                    await
                    Report3.
                    setTemplate(relatedTemplate3);
                }
            
                const relatedTemplate4 = await ReportTemplates.findOne({
                    offset: Math.floor(Math.random() * (await ReportTemplates.count())),
                });
                const Report4 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Report4?.setTemplate)
                {
                    await
                    Report4.
                    setTemplate(relatedTemplate4);
                }
            
        }
        
    
        
            
            async function associateReportWithGenerated_by() {
            
                const relatedGenerated_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Report0 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Report0?.setGenerated_by)
                {
                    await
                    Report0.
                    setGenerated_by(relatedGenerated_by0);
                }
            
                const relatedGenerated_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Report1 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Report1?.setGenerated_by)
                {
                    await
                    Report1.
                    setGenerated_by(relatedGenerated_by1);
                }
            
                const relatedGenerated_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Report2 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Report2?.setGenerated_by)
                {
                    await
                    Report2.
                    setGenerated_by(relatedGenerated_by2);
                }
            
                const relatedGenerated_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Report3 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Report3?.setGenerated_by)
                {
                    await
                    Report3.
                    setGenerated_by(relatedGenerated_by3);
                }
            
                const relatedGenerated_by4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Report4 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Report4?.setGenerated_by)
                {
                    await
                    Report4.
                    setGenerated_by(relatedGenerated_by4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateReportWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Report0 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Report0?.setOrganization)
                {
                    await
                    Report0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Report1 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Report1?.setOrganization)
                {
                    await
                    Report1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Report2 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Report2?.setOrganization)
                {
                    await
                    Report2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Report3 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Report3?.setOrganization)
                {
                    await
                    Report3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Report4 = await Reports.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Report4?.setOrganization)
                {
                    await
                    Report4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateApiClientWithTenant() {
            
                const relatedTenant0 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ApiClient0 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApiClient0?.setTenant)
                {
                    await
                    ApiClient0.
                    setTenant(relatedTenant0);
                }
            
                const relatedTenant1 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ApiClient1 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApiClient1?.setTenant)
                {
                    await
                    ApiClient1.
                    setTenant(relatedTenant1);
                }
            
                const relatedTenant2 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ApiClient2 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApiClient2?.setTenant)
                {
                    await
                    ApiClient2.
                    setTenant(relatedTenant2);
                }
            
                const relatedTenant3 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ApiClient3 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApiClient3?.setTenant)
                {
                    await
                    ApiClient3.
                    setTenant(relatedTenant3);
                }
            
                const relatedTenant4 = await Tenants.findOne({
                    offset: Math.floor(Math.random() * (await Tenants.count())),
                });
                const ApiClient4 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApiClient4?.setTenant)
                {
                    await
                    ApiClient4.
                    setTenant(relatedTenant4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateApiClientWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ApiClient0 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApiClient0?.setOrganization)
                {
                    await
                    ApiClient0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ApiClient1 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApiClient1?.setOrganization)
                {
                    await
                    ApiClient1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ApiClient2 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApiClient2?.setOrganization)
                {
                    await
                    ApiClient2.
                    setOrganization(relatedOrganization2);
                }
            
                const relatedOrganization3 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ApiClient3 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApiClient3?.setOrganization)
                {
                    await
                    ApiClient3.
                    setOrganization(relatedOrganization3);
                }
            
                const relatedOrganization4 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ApiClient4 = await ApiClients.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApiClient4?.setOrganization)
                {
                    await
                    ApiClient4.
                    setOrganization(relatedOrganization4);
                }
            
        }
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Organizations.bulkCreate(OrganizationsData);
                
            
            
                
                await Tenants.bulkCreate(TenantsData);
                
            
            
                
                await Farms.bulkCreate(FarmsData);
                
            
            
                
                await Trials.bulkCreate(TrialsData);
                
            
            
                
                await TrialSites.bulkCreate(TrialSitesData);
                
            
            
                
                await Varieties.bulkCreate(VarietiesData);
                
            
            
                
                await TrialEntries.bulkCreate(TrialEntriesData);
                
            
            
                
                await Plots.bulkCreate(PlotsData);
                
            
            
                
                await Plants.bulkCreate(PlantsData);
                
            
            
                
                await ObservationEvents.bulkCreate(ObservationEventsData);
                
            
            
                
                await Traits.bulkCreate(TraitsData);
                
            
            
                
                await Observations.bulkCreate(ObservationsData);
                
            
            
                
                await MediaAssets.bulkCreate(MediaAssetsData);
                
            
            
                
                await ReportTemplates.bulkCreate(ReportTemplatesData);
                
            
            
                
                await Reports.bulkCreate(ReportsData);
                
            
            
                
                await ApiClients.bulkCreate(ApiClientsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateUserWithOrganization(),
                    
                
            
                
                
                
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateTenantWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateFarmWithTenant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateFarmWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTrialWithTenant(),
                    
                
                    
                        
                        await associateTrialWithFarm(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateTrialWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTrialSiteWithTrial(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTrialSiteWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateVarietyWithTenant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateVarietyWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTrialEntryWithTrial(),
                    
                
                    
                        
                        await associateTrialEntryWithVariety(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTrialEntryWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePlotWithTrial_site(),
                    
                
                    
                        
                        await associatePlotWithTrial_entry(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePlotWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePlantWithPlot(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePlantWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateObservationEventWithTrial(),
                    
                
                    
                        
                        await associateObservationEventWithTrial_site(),
                    
                
                    
                        
                        await associateObservationEventWithPlot(),
                    
                
                    
                        
                        await associateObservationEventWithPlant(),
                    
                
                    
                        
                        await associateObservationEventWithObserver(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateObservationEventWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTraitWithTenant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTraitWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateObservationWithObservation_event(),
                    
                
                    
                        
                        await associateObservationWithTrait(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateObservationWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateMediaAssetWithTenant(),
                    
                
                    
                        
                        await associateMediaAssetWithUploaded_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMediaAssetWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateReportTemplateWithTenant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateReportTemplateWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateReportWithTrial(),
                    
                
                    
                        
                        await associateReportWithTemplate(),
                    
                
                    
                        
                        await associateReportWithGenerated_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateReportWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateApiClientWithTenant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateApiClientWithOrganization(),
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('organizations', null, {});
            
            
            await queryInterface.bulkDelete('tenants', null, {});
            
            
            await queryInterface.bulkDelete('farms', null, {});
            
            
            await queryInterface.bulkDelete('trials', null, {});
            
            
            await queryInterface.bulkDelete('trial_sites', null, {});
            
            
            await queryInterface.bulkDelete('varieties', null, {});
            
            
            await queryInterface.bulkDelete('trial_entries', null, {});
            
            
            await queryInterface.bulkDelete('plots', null, {});
            
            
            await queryInterface.bulkDelete('plants', null, {});
            
            
            await queryInterface.bulkDelete('observation_events', null, {});
            
            
            await queryInterface.bulkDelete('traits', null, {});
            
            
            await queryInterface.bulkDelete('observations', null, {});
            
            
            await queryInterface.bulkDelete('media_assets', null, {});
            
            
            await queryInterface.bulkDelete('report_templates', null, {});
            
            
            await queryInterface.bulkDelete('reports', null, {});
            
            
            await queryInterface.bulkDelete('api_clients', null, {});
            
        
    },
};