





















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






const Organizations = db.organizations;

const UserInvitations = db.user_invitations;

const ConnectedSystems = db.connected_systems;

const ControlFrameworks = db.control_frameworks;

const ControlRequirements = db.control_requirements;

const IdentityWorkflows = db.identity_workflows;

const EvidenceModels = db.evidence_models;

const Artifacts = db.artifacts;

const SampledSubjects = db.sampled_subjects;

const ProofPackets = db.proof_packets;

const RemediationItems = db.remediation_items;

const AccessReviews = db.access_reviews;

const AccessReviewItems = db.access_review_items;

const Exceptions = db.exceptions;

const AuditLogs = db.audit_logs;

const Notifications = db.notifications;

const OrganizationSettings = db.organization_settings;

const ArtifactTypeCatalog = db.artifact_type_catalog;

const WorkflowTemplates = db.workflow_templates;







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



const UserInvitationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invitee_email": "kelly.brooks@redstonemissionsystems.com",
            
        
    
        
        
            
                "invitee_name": "Kelly Brooks",
            
        
    
        
        
            
                "role": "read_only_client",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invite_token_hash": "inv_hash_redstone_kelly_01",
            
        
    
        
        
            
                "expires_at": new Date('2026-04-20T00:00:00Z'),
            
        
    
        
        
            
                "status": "accepted",
            
        
    
        
        
            
                "accepted_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-01-02T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invitee_email": "alex.morgan@redstonemissionsystems.com",
            
        
    
        
        
            
                "invitee_name": "Alex Morgan",
            
        
    
        
        
            
                "role": "security_manager",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invite_token_hash": "inv_hash_redstone_alex_02",
            
        
    
        
        
            
                "expires_at": new Date('2026-04-18T00:00:00Z'),
            
        
    
        
        
            
                "status": "expired",
            
        
    
        
        
            
                "accepted_at": new Date('2026-04-05T14:12:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invitee_email": "sarah.kim@northbridgecp.com",
            
        
    
        
        
            
                "invitee_name": "Sarah Kim",
            
        
    
        
        
            
                "role": "org_admin",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invite_token_hash": "inv_hash_northbridge_sarah_01",
            
        
    
        
        
            
                "expires_at": new Date('2026-04-22T00:00:00Z'),
            
        
    
        
        
            
                "status": "accepted",
            
        
    
        
        
            
                "accepted_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-01-02T00:00:00Z'),
            
        
    
    },
    
];



const ConnectedSystemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "system_name": "Entra ID Tenant",
            
        
    
        
        
            
                "system_type": "endpoint_mdm",
            
        
    
        
        
            
                "vendor": "Microsoft",
            
        
    
        
        
            
                "environment": "unknown",
            
        
    
        
        
            
                "owner": "IT Security",
            
        
    
        
        
            
                "connection_status": "not_configured",
            
        
    
        
        
            
                "last_successful_sync_at": new Date('2026-04-09T19:00:00Z'),
            
        
    
        
        
            
                "connection_health_notes": "Graph API token valid; nightly sync healthy.",
            
        
    
        
        
            
                "source_of_truth_flag": true,
            
        
    
        
        
            
                "notes": "Primary identity provider for workforce accounts.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "system_name": "Microsoft 365 Unified Audit Log",
            
        
    
        
        
            
                "system_type": "custom_source",
            
        
    
        
        
            
                "vendor": "Microsoft",
            
        
    
        
        
            
                "environment": "sandbox",
            
        
    
        
        
            
                "owner": "Security Operations",
            
        
    
        
        
            
                "connection_status": "not_configured",
            
        
    
        
        
            
                "last_successful_sync_at": new Date('2026-04-09T19:10:00Z'),
            
        
    
        
        
            
                "connection_health_notes": "Audit log export configured; retention verified.",
            
        
    
        
        
            
                "source_of_truth_flag": true,
            
        
    
        
        
            
                "notes": "Used for mailbox access and admin activity evidence.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "system_name": "ServiceNow ITSM",
            
        
    
        
        
            
                "system_type": "microsoft_365_audit",
            
        
    
        
        
            
                "vendor": "ServiceNow",
            
        
    
        
        
            
                "environment": "production",
            
        
    
        
        
            
                "owner": "IT Operations",
            
        
    
        
        
            
                "connection_status": "degraded",
            
        
    
        
        
            
                "last_successful_sync_at": new Date('2026-04-08T02:00:00Z'),
            
        
    
        
        
            
                "connection_health_notes": "API rate limits observed; increase backoff.",
            
        
    
        
        
            
                "source_of_truth_flag": false,
            
        
    
        
        
            
                "notes": "Joiner mover leaver tickets and approvals.",
            
        
    
    },
    
];



const ControlFrameworksData = [
    
    {
    
        
        
            
                "framework_name": "CMMC Level 2",
            
        
    
        
        
            
                "version": "2.0",
            
        
    
        
        
            
                "description": "Cybersecurity Maturity Model Certification Level 2 controls for defense contractors.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "framework_name": "SOC 2",
            
        
    
        
        
            
                "version": "2018",
            
        
    
        
        
            
                "description": "AICPA Trust Services Criteria for SOC 2 Type II audits.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "framework_name": "ISO 27001",
            
        
    
        
        
            
                "version": "2022",
            
        
    
        
        
            
                "description": "ISO IEC 27001:2022 information security management controls.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ControlRequirementsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "control_code": "AC.L2-3.1.2",
            
        
    
        
        
            
                "control_family": "Access Control",
            
        
    
        
        
            
                "control_title": "Limit system access to authorized users",
            
        
    
        
        
            
                "control_description": "Limit information system access to authorized users and permitted actions.",
            
        
    
        
        
            
                "evidence_expectation_summary": "User lifecycle tickets, account disable logs, and access review records.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "control_code": "AC.L2-3.1.5",
            
        
    
        
        
            
                "control_family": "Access Control",
            
        
    
        
        
            
                "control_title": "Least privilege and privileged accounts",
            
        
    
        
        
            
                "control_description": "Employ least privilege including specific security functions and privileged accounts.",
            
        
    
        
        
            
                "evidence_expectation_summary": "Privileged group membership changes, PAM assignment approvals, session logs.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "control_code": "CC6.2",
            
        
    
        
        
            
                "control_family": "Logical and Physical Access",
            
        
    
        
        
            
                "control_title": "User access provisioning and deprovisioning",
            
        
    
        
        
            
                "control_description": "Authorize and revoke access based on role changes and termination.",
            
        
    
        
        
            
                "evidence_expectation_summary": "HR trigger, ticket approvals, IdP logs showing disable and group removals.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const IdentityWorkflowsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "workflow_name": "M365 Offboarding",
            
        
    
        
        
            
                "workflow_type": "leaver",
            
        
    
        
        
            
                "description": "Offboarding workflow covering Entra disable, mailbox access handoff, and group removals.",
            
        
    
        
        
            
                "risk_level": "low",
            
        
    
        
        
            
                "owner_role": "compliance_manager",
            
        
    
        
        
            
                "source_trigger_type": "Manual",
            
        
    
        
        
            
                "status": "deprecated",
            
        
    
        
        
            
                "recurrence_type": "quarterly",
            
        
    
        
        
            
                "target_sla_hours": 24,
            
        
    
        
        
            
                "coverage_gap_notes": "Need stronger proof of mailbox delegate removal in some cases.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "workflow_name": "Privileged Access Assignment",
            
        
    
        
        
            
                "workflow_type": "privileged_access_removal",
            
        
    
        
        
            
                "description": "Controlled assignment to privileged groups with approval and PAM enrollment.",
            
        
    
        
        
            
                "risk_level": "medium",
            
        
    
        
        
            
                "owner_role": "auditor",
            
        
    
        
        
            
                "source_trigger_type": "Manual",
            
        
    
        
        
            
                "status": "deprecated",
            
        
    
        
        
            
                "recurrence_type": "annual",
            
        
    
        
        
            
                "target_sla_hours": 8,
            
        
    
        
        
            
                "coverage_gap_notes": "Ensure approver identity captured in every ticket export.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "workflow_name": "Quarterly Finance Access Review",
            
        
    
        
        
            
                "workflow_type": "leaver",
            
        
    
        
        
            
                "description": "Quarterly review of finance application access and privileged group membership.",
            
        
    
        
        
            
                "risk_level": "high",
            
        
    
        
        
            
                "owner_role": "compliance_manager",
            
        
    
        
        
            
                "source_trigger_type": "Automated",
            
        
    
        
        
            
                "status": "deprecated",
            
        
    
        
        
            
                "recurrence_type": "weekly",
            
        
    
        
        
            
                "target_sla_hours": 168,
            
        
    
        
        
            
                "coverage_gap_notes": "Reviewer justifications sometimes missing in exports.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
];



const EvidenceModelsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "evidence_claim": "Terminated user account is disabled within SLA and access is revoked across critical groups.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "artifact_type": "export_csv",
            
        
    
        
        
            
                "required_fields": "userPrincipalName disableTime actor ticketReference groupRemovalProof",
            
        
    
        
        
            
                "approval_required_flag": true,
            
        
    
        
        
            
                "retention_period": "indefinite",
            
        
    
        
        
            
                "evidence_strength": "moderate",
            
        
    
        
        
            
                "collection_method": "attestation",
            
        
    
        
        
            
                "notes": "Prefer Graph audit logs plus ticket approval export.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "evidence_claim": "Offboarding is initiated by HR trigger and approved via ITSM ticket.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "artifact_type": "attestation",
            
        
    
        
        
            
                "required_fields": "ticketId requestor approver approvalTime closureTime terminatedDate",
            
        
    
        
        
            
                "approval_required_flag": true,
            
        
    
        
        
            
                "retention_period": "7_years",
            
        
    
        
        
            
                "evidence_strength": "strong",
            
        
    
        
        
            
                "collection_method": "attestation",
            
        
    
        
        
            
                "notes": "Ticket export must include approval history and timestamps.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "evidence_claim": "Privileged access assignments require documented approval and are time-bounded where feasible.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "artifact_type": "api_snapshot",
            
        
    
        
        
            
                "required_fields": "accountName safeName roleGranted approver grantedAt expiresAt sessionLink",
            
        
    
        
        
            
                "approval_required_flag": true,
            
        
    
        
        
            
                "retention_period": "180_days",
            
        
    
        
        
            
                "evidence_strength": "weak",
            
        
    
        
        
            
                "collection_method": "export",
            
        
    
        
        
            
                "notes": "Capture session recording URL or session ID for chain of custody.",
            
        
    
    },
    
];



const ArtifactsData = [
    
    {
    
        
        
            
                // 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
            
        
    
        
        
            
                "artifact_name": "Entra disable log for jnelson",
            
        
    
        
        
            
                "artifact_type": "other",
            
        
    
        
        
            
                "artifact_reference": "https://entra.example.com/audit/disable/jnelson-2026-03-18",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "collected_at": new Date('2026-03-18T17:05:00Z'),
            
        
    
        
        
            
                "event_timestamp": new Date('2026-03-18T16:52:00Z'),
            
        
    
        
        
            
                "subject_user": "jnelson@redstonemissionsystems.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "validation_notes": "Disable event and actor confirmed; group removals attached in related export.",
            
        
    
        
        
            
                "evidence_strength_score": 0.92,
            
        
    
        
        
            
                "chain_integrity_score": 0.88,
            
        
    
        
        
            
                "retention_expiry": new Date('2029-03-18T00:00:00Z'),
            
        
    
        
        
            
                "tags": "offboarding entra strong",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "artifact_name": "ServiceNow ticket INC0048211 offboarding jnelson",
            
        
    
        
        
            
                "artifact_type": "api_snapshot",
            
        
    
        
        
            
                "artifact_reference": "https://servicenow.example.com/nav_to.do?uri=incident.do?sys_id=INC0048211",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "collected_at": new Date('2026-03-18T17:10:00Z'),
            
        
    
        
        
            
                "event_timestamp": new Date('2026-03-18T15:40:00Z'),
            
        
    
        
        
            
                "subject_user": "jnelson@redstonemissionsystems.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "validation_notes": "Approval and closure timestamps present; HR trigger referenced.",
            
        
    
        
        
            
                "evidence_strength_score": 0.78,
            
        
    
        
        
            
                "chain_integrity_score": 0.81,
            
        
    
        
        
            
                "retention_expiry": new Date('2029-03-18T00:00:00Z'),
            
        
    
        
        
            
                "tags": "offboarding ticket approval",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "artifact_name": "CyberArk vault admin assignment for dkirks",
            
        
    
        
        
            
                "artifact_type": "export_json",
            
        
    
        
        
            
                "artifact_reference": "https://cyberark.example.com/audit/assign/dkirks-2026-04-02",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "collected_at": new Date('2026-04-02T15:22:00Z'),
            
        
    
        
        
            
                "event_timestamp": new Date('2026-04-02T15:10:00Z'),
            
        
    
        
        
            
                "subject_user": "dkirks@redstonemissionsystems.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "validation_notes": "Session recording link pending.",
            
        
    
        
        
            
                "evidence_strength_score": 0.7,
            
        
    
        
        
            
                "chain_integrity_score": 0.62,
            
        
    
        
        
            
                "retention_expiry": new Date('2033-04-02T00:00:00Z'),
            
        
    
        
        
            
                "tags": "pam privileged pending_validation",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const SampledSubjectsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sample_type": "reviewed_user",
            
        
    
        
        
            
                "display_name": "Jordan Nelson",
            
        
    
        
        
            
                "identifier": "jnelson@redstonemissionsystems.com",
            
        
    
        
        
            
                "department": "Engineering",
            
        
    
        
        
            
                "role_name": "Systems Engineer",
            
        
    
        
        
            
                "manager": "Cameron Blake",
            
        
    
        
        
            
                "event_date": new Date('2026-03-18T00:00:00Z'),
            
        
    
        
        
            
                "risk_tier": "critical",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "notes": "Sampled for CMMC offboarding evidence packet.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sample_type": "privileged_admin",
            
        
    
        
        
            
                "display_name": "Dana Kirk",
            
        
    
        
        
            
                "identifier": "dkirks@redstonemissionsystems.com",
            
        
    
        
        
            
                "department": "IT",
            
        
    
        
        
            
                "role_name": "IAM Analyst",
            
        
    
        
        
            
                "manager": "Samir Qureshi",
            
        
    
        
        
            
                "event_date": new Date('2026-04-02T00:00:00Z'),
            
        
    
        
        
            
                "risk_tier": "medium",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "notes": "Privileged assignment requires session link evidence.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sample_type": "onboarded_user",
            
        
    
        
        
            
                "display_name": "Maya Grant",
            
        
    
        
        
            
                "identifier": "maya.grant@ironledgermsp.com",
            
        
    
        
        
            
                "department": "Finance",
            
        
    
        
        
            
                "role_name": "AR Specialist",
            
        
    
        
        
            
                "manager": "Sofia Martinez",
            
        
    
        
        
            
                "event_date": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "risk_tier": "critical",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "notes": "Included in Q1 access review sample for SOC 2.",
            
        
    
    },
    
];



const ProofPacketsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "packet_name": "CMMC Offboarding Proof Packet Jordan Nelson",
            
        
    
        
        
            
                "packet_type": "access_review",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "packet_status": "delivered",
            
        
    
        
        
            
                "readiness_score": 0.91,
            
        
    
        
        
            
                "generated_on": new Date('2026-03-20T16:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Offboarding evidence demonstrating HR trigger, ticket approval, Entra disable event, and retention metadata.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "packet_name": "Privileged Access Assignment Packet Dana Kirk",
            
        
    
        
        
            
                "packet_type": "privileged_access",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "packet_status": "ready",
            
        
    
        
        
            
                "readiness_score": 0.68,
            
        
    
        
        
            
                "generated_on": new Date('2026-04-03T12:30:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-30T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Packet for privileged assignment requires session recording link and explicit ticket approval export.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "packet_name": "SOC2 Q1 2026 Finance Access Review Packet",
            
        
    
        
        
            
                "packet_type": "service_account",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "packet_status": "delivered",
            
        
    
        
        
            
                "readiness_score": 0.86,
            
        
    
        
        
            
                "generated_on": new Date('2026-04-02T15:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-05-01T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Quarterly access review evidence with reviewer decisions and escalations tracked.",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
];



const RemediationItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "Add PAM session recording links to privileged access evidence",
            
        
    
        
        
            
                "description": "Privileged access assignment artifacts lack session recording URLs. Update collection checklist and enforce required field in evidence model.",
            
        
    
        
        
            
                "severity": "low",
            
        
    
        
        
            
                "category": "mfa_gap",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "due_date": new Date('2026-04-20T00:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "remediation_plan": "Update CyberArk export query to include sessionId and recordingLink; re-collect last 10 assignments.",
            
        
    
        
        
            
                "completed_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "Capture reviewer justifications for all access review items",
            
        
    
        
        
            
                "description": "Some exported access review rows missing justification. Add mandatory justification step before marking items complete.",
            
        
    
        
        
            
                "severity": "high",
            
        
    
        
        
            
                "category": "other",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "due_date": new Date('2026-04-25T00:00:00Z'),
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "remediation_plan": "Add pre-export validation and training for reviewers; update review template fields.",
            
        
    
        
        
            
                "completed_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "Document MFA exception approvals for service accounts",
            
        
    
        
        
            
                "description": "Service account MFA exclusions must be explicitly approved and tied to exception records to maintain strong evidence.",
            
        
    
        
        
            
                "severity": "medium",
            
        
    
        
        
            
                "category": "missing_approval",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "due_date": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "remediation_plan": "Create exception record for svc-finance-integ and attach approval and compensating controls evidence.",
            
        
    
        
        
            
                "completed_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
    },
    
];



const AccessReviewsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "review_name": "Q1 2026 Finance Access Review",
            
        
    
        
        
            
                "review_scope": "Finance groups and finance application access for workforce users.",
            
        
    
        
        
            
                "review_type": "service_account",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_date": new Date('2026-03-20T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-05T00:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "completion_percentage": 100,
            
        
    
        
        
            
                "notes": "Two revocations executed; evidence exported and packet updated.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "review_name": "Q2 2026 Privileged Group Review",
            
        
    
        
        
            
                "review_scope": "Global admin, security admin, and privileged PAM roles.",
            
        
    
        
        
            
                "review_type": "app_access",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_date": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-20T00:00:00Z'),
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "completion_percentage": 55,
            
        
    
        
        
            
                "notes": "Pending decisions for two contractor accounts.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "review_name": "Client Tools Access Review April 2026",
            
        
    
        
        
            
                "review_scope": "Access to client evidence repositories and ticketing projects.",
            
        
    
        
        
            
                "review_type": "quarterly_user_access",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_date": new Date('2026-04-05T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-19T00:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "completion_percentage": 10,
            
        
    
        
        
            
                "notes": "Review launched; awaiting reviewer queue completion.",
            
        
    
    },
    
];



const AccessReviewItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_display_name": "Maya Grant",
            
        
    
        
        
            
                "subject_identifier": "maya.grant@ironledgermsp.com",
            
        
    
        
        
            
                "system_name": "Google Workspace",
            
        
    
        
        
            
                "entitlements_reviewed": "Finance Shared Drive access, Finance Group membership",
            
        
    
        
        
            
                "reviewer_decision": "approve",
            
        
    
        
        
            
                "justification": "Role requires ongoing access for accounts receivable processing.",
            
        
    
        
        
            
                "action_required": true,
            
        
    
        
        
            
                "completed_at": new Date('2026-04-01T13:10:00Z'),
            
        
    
        
        
            
                "status": "escalated",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_display_name": "Ethan Rowe",
            
        
    
        
        
            
                "subject_identifier": "ethan.rowe@ironledgermsp.com",
            
        
    
        
        
            
                "system_name": "Finance App",
            
        
    
        
        
            
                "entitlements_reviewed": "Finance app admin role",
            
        
    
        
        
            
                "reviewer_decision": "approve",
            
        
    
        
        
            
                "justification": "Transferred out of finance; admin access not required.",
            
        
    
        
        
            
                "action_required": true,
            
        
    
        
        
            
                "completed_at": new Date('2026-04-01T13:20:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_display_name": "Dana Kirk",
            
        
    
        
        
            
                "subject_identifier": "dkirks@redstonemissionsystems.com",
            
        
    
        
        
            
                "system_name": "Entra ID Tenant",
            
        
    
        
        
            
                "entitlements_reviewed": "Privileged role assignment and admin group memberships",
            
        
    
        
        
            
                "reviewer_decision": "no_change",
            
        
    
        
        
            
                "justification": "Active IAM operator; access validated against current responsibilities.",
            
        
    
        
        
            
                "action_required": false,
            
        
    
        
        
            
                "completed_at": new Date('2026-04-08T16:00:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
    },
    
];



const ExceptionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "exception_name": "Break Glass Admin Use March 22 2026",
            
        
    
        
        
            
                "exception_type": "temporary_privilege",
            
        
    
        
        
            
                "subject": "bg-admin@redstonemissionsystems.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Urgent tenant configuration change to restore email delivery.",
            
        
    
        
        
            
                "granted_at": new Date('2026-03-22T02:10:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2026-03-22T04:10:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-03-22T03:40:00Z'),
            
        
    
        
        
            
                "followup_review_required": true,
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "notes": "Follow-up review required within 48 hours; attach session recording once available.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "exception_name": "Service Account MFA Exclusion svc-finance-integ",
            
        
    
        
        
            
                "exception_type": "policy_exception",
            
        
    
        
        
            
                "subject": "svc-finance-integ@ironledgermsp.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Legacy integration does not support modern MFA; compensating controls applied.",
            
        
    
        
        
            
                "granted_at": new Date('2026-03-31T23:15:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2026-06-30T00:00:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "followup_review_required": true,
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "notes": "Add written approval and quarterly review cadence.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "exception_name": "Emergency Access Use April 05 2026",
            
        
    
        
        
            
                "exception_type": "policy_exception",
            
        
    
        
        
            
                "subject": "dkirks@redstonemissionsystems.com",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "Restore access to privileged group after mistaken removal during incident response.",
            
        
    
        
        
            
                "granted_at": new Date('2026-04-05T19:05:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2026-04-05T21:05:00Z'),
            
        
    
        
        
            
                "revoked_at": new Date('2026-04-05T20:40:00Z'),
            
        
    
        
        
            
                "followup_review_required": true,
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "notes": "Attach correct Entra role change export for this event.",
            
        
    
    },
    
];



const AuditLogsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action_type": "validation",
            
        
    
        
        
            
                "target_entity_type": "proof_packet",
            
        
    
        
        
            
                "target_entity_key": "invite kelly.brooks@redstonemissionsystems.com",
            
        
    
        
        
            
                "timestamp": new Date('2026-04-06T13:00:00Z'),
            
        
    
        
        
            
                "before_state_summary": "No invitation existed",
            
        
    
        
        
            
                "after_state_summary": "Invitation pending for auditor role",
            
        
    
        
        
            
                "ip_address": "198.51.100.10",
            
        
    
        
        
            
                "user_agent": "Chrome 123 macOS",
            
        
    
        
        
            
                "notes": "Invited auditor for assessment support.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action_type": "delete",
            
        
    
        
        
            
                "target_entity_type": "artifact",
            
        
    
        
        
            
                "target_entity_key": "Entra disable log for jnelson",
            
        
    
        
        
            
                "timestamp": new Date('2026-03-18T17:05:30Z'),
            
        
    
        
        
            
                "before_state_summary": "Artifact not present",
            
        
    
        
        
            
                "after_state_summary": "Artifact created with reference URL and timestamps",
            
        
    
        
        
            
                "ip_address": "198.51.100.24",
            
        
    
        
        
            
                "user_agent": "Chrome 123 Windows",
            
        
    
        
        
            
                "notes": "Collected via export and linked to evidence model.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action_type": "invite_accepted",
            
        
    
        
        
            
                "target_entity_type": "organization",
            
        
    
        
        
            
                "target_entity_key": "SOC2 Q1 2026 Finance Access Review Packet",
            
        
    
        
        
            
                "timestamp": new Date('2026-04-02T15:10:00Z'),
            
        
    
        
        
            
                "before_state_summary": "Packet in_review readiness 0.74",
            
        
    
        
        
            
                "after_state_summary": "Packet ready readiness 0.86",
            
        
    
        
        
            
                "ip_address": "203.0.113.9",
            
        
    
        
        
            
                "user_agent": "Edge 122 Windows",
            
        
    
        
        
            
                "notes": "Added final access review export artifact.",
            
        
    
    },
    
];



const NotificationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notification_type": "packet_due",
            
        
    
        
        
            
                "title": "Proof packet due soon",
            
        
    
        
        
            
                "message": "CMMC Offboarding Proof Packet Jordan Nelson due on 2026-04-15.",
            
        
    
        
        
            
                "priority": "high",
            
        
    
        
        
            
                "read_flag": false,
            
        
    
        
        
            
                "read_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "target_entity_type": "identity_workflow",
            
        
    
        
        
            
                "target_entity_key": "CMMC Offboarding Proof Packet Jordan Nelson",
            
        
    
        
        
            
                "scheduled_for": new Date('2026-04-10T09:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notification_type": "remediation_overdue",
            
        
    
        
        
            
                "title": "Artifact pending validation",
            
        
    
        
        
            
                "message": "CyberArk vault admin assignment for dkirks needs validation notes and session link.",
            
        
    
        
        
            
                "priority": "high",
            
        
    
        
        
            
                "read_flag": true,
            
        
    
        
        
            
                "read_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "target_entity_type": "proof_packet",
            
        
    
        
        
            
                "target_entity_key": "CyberArk vault admin assignment for dkirks",
            
        
    
        
        
            
                "scheduled_for": new Date('2026-04-03T09:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notification_type": "comment_mention",
            
        
    
        
        
            
                "title": "Remediation item requires attention",
            
        
    
        
        
            
                "message": "Document MFA exception approvals for service accounts is blocked and due 2026-04-15.",
            
        
    
        
        
            
                "priority": "normal",
            
        
    
        
        
            
                "read_flag": true,
            
        
    
        
        
            
                "read_at": new Date('2026-04-09T12:00:00Z'),
            
        
    
        
        
            
                "target_entity_type": "access_review",
            
        
    
        
        
            
                "target_entity_key": "Document MFA exception approvals for service accounts",
            
        
    
        
        
            
                "scheduled_for": new Date('2026-04-09T08:00:00Z'),
            
        
    
    },
    
];



const OrganizationSettingsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "default_retention_period": "1_year",
            
        
    
        
        
            
                "require_mfa_for_all_users": true,
            
        
    
        
        
            
                "enable_global_search": true,
            
        
    
        
        
            
                "enable_control_framework_library": true,
            
        
    
        
        
            
                "date_format": "mm_dd_yyyy",
            
        
    
        
        
            
                "branding_primary_color": "#0B1220",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "notification_email_from_name": "Redstone Compliance Ops",
            
        
    
        
        
            
                "notification_email_from_address": "no-reply@redstonemissionsystems.com",
            
        
    
        
        
            
                "slack_webhook_url": "https://hooks.slack.com/services/T000/B000/redstone",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "default_retention_period": "90_days",
            
        
    
        
        
            
                "require_mfa_for_all_users": true,
            
        
    
        
        
            
                "enable_global_search": true,
            
        
    
        
        
            
                "enable_control_framework_library": true,
            
        
    
        
        
            
                "date_format": "mm_dd_yyyy",
            
        
    
        
        
            
                "branding_primary_color": "#111827",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "notification_email_from_name": "Northbridge Evidence Desk",
            
        
    
        
        
            
                "notification_email_from_address": "no-reply@northbridgecp.com",
            
        
    
        
        
            
                "slack_webhook_url": "https://hooks.slack.com/services/T000/B000/northbridge",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "default_retention_period": "3_years",
            
        
    
        
        
            
                "require_mfa_for_all_users": true,
            
        
    
        
        
            
                "enable_global_search": true,
            
        
    
        
        
            
                "enable_control_framework_library": true,
            
        
    
        
        
            
                "date_format": "dd_mm_yyyy",
            
        
    
        
        
            
                "branding_primary_color": "#0F172A",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "notification_email_from_name": "Iron Ledger Compliance",
            
        
    
        
        
            
                "notification_email_from_address": "no-reply@ironledgermsp.com",
            
        
    
        
        
            
                "slack_webhook_url": "https://hooks.slack.com/services/T000/B000/ironledger",
            
        
    
    },
    
];



const ArtifactTypeCatalogData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type_name": "PAM session log",
            
        
    
        
        
            
                "description": "Audit export containing privileged session identifiers and recording references.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type_name": "Offboarding ticket export",
            
        
    
        
        
            
                "description": "ITSM export for joiner mover leaver records including approvals and timestamps.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type_name": "Access review export",
            
        
    
        
        
            
                "description": "CSV export of access review decisions and justifications.",
            
        
    
        
        
            
                "active_flag": true,
            
        
    
    },
    
];



const WorkflowTemplatesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "Standard Offboarding M365",
            
        
    
        
        
            
                "workflow_type": "mover",
            
        
    
        
        
            
                "description": "Template for M365 offboarding with HR trigger, ticket approval, IdP disable, and audit log capture.",
            
        
    
        
        
            
                "risk_level": "low",
            
        
    
        
        
            
                "owner_role": "auditor",
            
        
    
        
        
            
                "source_trigger_type": "HR",
            
        
    
        
        
            
                "recurrence_type": "none",
            
        
    
        
        
            
                "default_required_fields": "ticketId approver approvalTime disableTime actor groupRemovalProof",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "Privileged Assignment with PAM",
            
        
    
        
        
            
                "workflow_type": "privileged_access_assignment",
            
        
    
        
        
            
                "description": "Template requiring ticket approval plus PAM assignment and session recording link.",
            
        
    
        
        
            
                "risk_level": "medium",
            
        
    
        
        
            
                "owner_role": "read_only_client",
            
        
    
        
        
            
                "source_trigger_type": "Scheduled",
            
        
    
        
        
            
                "recurrence_type": "weekly",
            
        
    
        
        
            
                "default_required_fields": "requestId approver grantedAt expiresAt sessionLink",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "Quarterly Access Review Base",
            
        
    
        
        
            
                "workflow_type": "leaver",
            
        
    
        
        
            
                "description": "Template for quarterly access review cycles with decision and justification capture.",
            
        
    
        
        
            
                "risk_level": "medium",
            
        
    
        
        
            
                "owner_role": "security_manager",
            
        
    
        
        
            
                "source_trigger_type": "HR",
            
        
    
        
        
            
                "recurrence_type": "monthly",
            
        
    
        
        
            
                "default_required_fields": "reviewName reviewer decision justification completedAt",
            
        
    
    },
    
];




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

    
    
    
    
    
        
    

    
    
    
        
            
            async function associateUserInvitationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const UserInvitation0 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (UserInvitation0?.setOrganization)
                {
                    await
                    UserInvitation0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const UserInvitation1 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (UserInvitation1?.setOrganization)
                {
                    await
                    UserInvitation1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const UserInvitation2 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (UserInvitation2?.setOrganization)
                {
                    await
                    UserInvitation2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateUserInvitationWithInvited_by_user() {
            
                const relatedInvited_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const UserInvitation0 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (UserInvitation0?.setInvited_by_user)
                {
                    await
                    UserInvitation0.
                    setInvited_by_user(relatedInvited_by_user0);
                }
            
                const relatedInvited_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const UserInvitation1 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (UserInvitation1?.setInvited_by_user)
                {
                    await
                    UserInvitation1.
                    setInvited_by_user(relatedInvited_by_user1);
                }
            
                const relatedInvited_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const UserInvitation2 = await UserInvitations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (UserInvitation2?.setInvited_by_user)
                {
                    await
                    UserInvitation2.
                    setInvited_by_user(relatedInvited_by_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateConnectedSystemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ConnectedSystem0 = await ConnectedSystems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ConnectedSystem0?.setOrganization)
                {
                    await
                    ConnectedSystem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ConnectedSystem1 = await ConnectedSystems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ConnectedSystem1?.setOrganization)
                {
                    await
                    ConnectedSystem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ConnectedSystem2 = await ConnectedSystems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ConnectedSystem2?.setOrganization)
                {
                    await
                    ConnectedSystem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateControlFrameworkWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlFramework0 = await ControlFrameworks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ControlFramework0?.setOrganization)
                {
                    await
                    ControlFramework0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlFramework1 = await ControlFrameworks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ControlFramework1?.setOrganization)
                {
                    await
                    ControlFramework1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlFramework2 = await ControlFrameworks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ControlFramework2?.setOrganization)
                {
                    await
                    ControlFramework2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateControlRequirementWithFramework() {
            
                const relatedFramework0 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ControlRequirement0 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ControlRequirement0?.setFramework)
                {
                    await
                    ControlRequirement0.
                    setFramework(relatedFramework0);
                }
            
                const relatedFramework1 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ControlRequirement1 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ControlRequirement1?.setFramework)
                {
                    await
                    ControlRequirement1.
                    setFramework(relatedFramework1);
                }
            
                const relatedFramework2 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ControlRequirement2 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ControlRequirement2?.setFramework)
                {
                    await
                    ControlRequirement2.
                    setFramework(relatedFramework2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateControlRequirementWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlRequirement0 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ControlRequirement0?.setOrganization)
                {
                    await
                    ControlRequirement0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlRequirement1 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ControlRequirement1?.setOrganization)
                {
                    await
                    ControlRequirement1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ControlRequirement2 = await ControlRequirements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ControlRequirement2?.setOrganization)
                {
                    await
                    ControlRequirement2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

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

    
    
    
        
            
            async function associateEvidenceModelWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EvidenceModel0 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EvidenceModel0?.setOrganization)
                {
                    await
                    EvidenceModel0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EvidenceModel1 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EvidenceModel1?.setOrganization)
                {
                    await
                    EvidenceModel1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const EvidenceModel2 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EvidenceModel2?.setOrganization)
                {
                    await
                    EvidenceModel2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
            
            async function associateEvidenceModelWithWorkflow() {
            
                const relatedWorkflow0 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const EvidenceModel0 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EvidenceModel0?.setWorkflow)
                {
                    await
                    EvidenceModel0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const EvidenceModel1 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EvidenceModel1?.setWorkflow)
                {
                    await
                    EvidenceModel1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const EvidenceModel2 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EvidenceModel2?.setWorkflow)
                {
                    await
                    EvidenceModel2.
                    setWorkflow(relatedWorkflow2);
                }
            
        }
        
    
        
            
            async function associateEvidenceModelWithControl_requirement() {
            
                const relatedControl_requirement0 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const EvidenceModel0 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EvidenceModel0?.setControl_requirement)
                {
                    await
                    EvidenceModel0.
                    setControl_requirement(relatedControl_requirement0);
                }
            
                const relatedControl_requirement1 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const EvidenceModel1 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EvidenceModel1?.setControl_requirement)
                {
                    await
                    EvidenceModel1.
                    setControl_requirement(relatedControl_requirement1);
                }
            
                const relatedControl_requirement2 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const EvidenceModel2 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EvidenceModel2?.setControl_requirement)
                {
                    await
                    EvidenceModel2.
                    setControl_requirement(relatedControl_requirement2);
                }
            
        }
        
    
        
    
        
            
            async function associateEvidenceModelWithSource_system() {
            
                const relatedSource_system0 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const EvidenceModel0 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EvidenceModel0?.setSource_system)
                {
                    await
                    EvidenceModel0.
                    setSource_system(relatedSource_system0);
                }
            
                const relatedSource_system1 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const EvidenceModel1 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EvidenceModel1?.setSource_system)
                {
                    await
                    EvidenceModel1.
                    setSource_system(relatedSource_system1);
                }
            
                const relatedSource_system2 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const EvidenceModel2 = await EvidenceModels.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EvidenceModel2?.setSource_system)
                {
                    await
                    EvidenceModel2.
                    setSource_system(relatedSource_system2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateArtifactWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setOrganization)
                {
                    await
                    Artifact0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setOrganization)
                {
                    await
                    Artifact1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setOrganization)
                {
                    await
                    Artifact2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
            
            async function associateArtifactWithWorkflow() {
            
                const relatedWorkflow0 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setWorkflow)
                {
                    await
                    Artifact0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setWorkflow)
                {
                    await
                    Artifact1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setWorkflow)
                {
                    await
                    Artifact2.
                    setWorkflow(relatedWorkflow2);
                }
            
        }
        
    
        
            
            async function associateArtifactWithEvidence_model() {
            
                const relatedEvidence_model0 = await EvidenceModels.findOne({
                    offset: Math.floor(Math.random() * (await EvidenceModels.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setEvidence_model)
                {
                    await
                    Artifact0.
                    setEvidence_model(relatedEvidence_model0);
                }
            
                const relatedEvidence_model1 = await EvidenceModels.findOne({
                    offset: Math.floor(Math.random() * (await EvidenceModels.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setEvidence_model)
                {
                    await
                    Artifact1.
                    setEvidence_model(relatedEvidence_model1);
                }
            
                const relatedEvidence_model2 = await EvidenceModels.findOne({
                    offset: Math.floor(Math.random() * (await EvidenceModels.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setEvidence_model)
                {
                    await
                    Artifact2.
                    setEvidence_model(relatedEvidence_model2);
                }
            
        }
        
    
        
            
            async function associateArtifactWithSource_system() {
            
                const relatedSource_system0 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setSource_system)
                {
                    await
                    Artifact0.
                    setSource_system(relatedSource_system0);
                }
            
                const relatedSource_system1 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setSource_system)
                {
                    await
                    Artifact1.
                    setSource_system(relatedSource_system1);
                }
            
                const relatedSource_system2 = await ConnectedSystems.findOne({
                    offset: Math.floor(Math.random() * (await ConnectedSystems.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setSource_system)
                {
                    await
                    Artifact2.
                    setSource_system(relatedSource_system2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateArtifactWithCollected_by_user() {
            
                const relatedCollected_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setCollected_by_user)
                {
                    await
                    Artifact0.
                    setCollected_by_user(relatedCollected_by_user0);
                }
            
                const relatedCollected_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setCollected_by_user)
                {
                    await
                    Artifact1.
                    setCollected_by_user(relatedCollected_by_user1);
                }
            
                const relatedCollected_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setCollected_by_user)
                {
                    await
                    Artifact2.
                    setCollected_by_user(relatedCollected_by_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateArtifactWithApprover_user() {
            
                const relatedApprover_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact0 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Artifact0?.setApprover_user)
                {
                    await
                    Artifact0.
                    setApprover_user(relatedApprover_user0);
                }
            
                const relatedApprover_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact1 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Artifact1?.setApprover_user)
                {
                    await
                    Artifact1.
                    setApprover_user(relatedApprover_user1);
                }
            
                const relatedApprover_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Artifact2 = await Artifacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Artifact2?.setApprover_user)
                {
                    await
                    Artifact2.
                    setApprover_user(relatedApprover_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateSampledSubjectWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SampledSubject0 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SampledSubject0?.setOrganization)
                {
                    await
                    SampledSubject0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SampledSubject1 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SampledSubject1?.setOrganization)
                {
                    await
                    SampledSubject1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SampledSubject2 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SampledSubject2?.setOrganization)
                {
                    await
                    SampledSubject2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSampledSubjectWithWorkflow() {
            
                const relatedWorkflow0 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const SampledSubject0 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SampledSubject0?.setWorkflow)
                {
                    await
                    SampledSubject0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const SampledSubject1 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SampledSubject1?.setWorkflow)
                {
                    await
                    SampledSubject1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const SampledSubject2 = await SampledSubjects.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SampledSubject2?.setWorkflow)
                {
                    await
                    SampledSubject2.
                    setWorkflow(relatedWorkflow2);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateProofPacketWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProofPacket0 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProofPacket0?.setOrganization)
                {
                    await
                    ProofPacket0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProofPacket1 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProofPacket1?.setOrganization)
                {
                    await
                    ProofPacket1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ProofPacket2 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProofPacket2?.setOrganization)
                {
                    await
                    ProofPacket2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateProofPacketWithFramework() {
            
                const relatedFramework0 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ProofPacket0 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProofPacket0?.setFramework)
                {
                    await
                    ProofPacket0.
                    setFramework(relatedFramework0);
                }
            
                const relatedFramework1 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ProofPacket1 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProofPacket1?.setFramework)
                {
                    await
                    ProofPacket1.
                    setFramework(relatedFramework1);
                }
            
                const relatedFramework2 = await ControlFrameworks.findOne({
                    offset: Math.floor(Math.random() * (await ControlFrameworks.count())),
                });
                const ProofPacket2 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProofPacket2?.setFramework)
                {
                    await
                    ProofPacket2.
                    setFramework(relatedFramework2);
                }
            
        }
        
    
        
            
            async function associateProofPacketWithWorkflow() {
            
                const relatedWorkflow0 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const ProofPacket0 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProofPacket0?.setWorkflow)
                {
                    await
                    ProofPacket0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const ProofPacket1 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProofPacket1?.setWorkflow)
                {
                    await
                    ProofPacket1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const ProofPacket2 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProofPacket2?.setWorkflow)
                {
                    await
                    ProofPacket2.
                    setWorkflow(relatedWorkflow2);
                }
            
        }
        
    
        
            
            async function associateProofPacketWithSampled_subject() {
            
                const relatedSampled_subject0 = await SampledSubjects.findOne({
                    offset: Math.floor(Math.random() * (await SampledSubjects.count())),
                });
                const ProofPacket0 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProofPacket0?.setSampled_subject)
                {
                    await
                    ProofPacket0.
                    setSampled_subject(relatedSampled_subject0);
                }
            
                const relatedSampled_subject1 = await SampledSubjects.findOne({
                    offset: Math.floor(Math.random() * (await SampledSubjects.count())),
                });
                const ProofPacket1 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProofPacket1?.setSampled_subject)
                {
                    await
                    ProofPacket1.
                    setSampled_subject(relatedSampled_subject1);
                }
            
                const relatedSampled_subject2 = await SampledSubjects.findOne({
                    offset: Math.floor(Math.random() * (await SampledSubjects.count())),
                });
                const ProofPacket2 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProofPacket2?.setSampled_subject)
                {
                    await
                    ProofPacket2.
                    setSampled_subject(relatedSampled_subject2);
                }
            
        }
        
    
        
            
            async function associateProofPacketWithOwner_user() {
            
                const relatedOwner_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProofPacket0 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProofPacket0?.setOwner_user)
                {
                    await
                    ProofPacket0.
                    setOwner_user(relatedOwner_user0);
                }
            
                const relatedOwner_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProofPacket1 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProofPacket1?.setOwner_user)
                {
                    await
                    ProofPacket1.
                    setOwner_user(relatedOwner_user1);
                }
            
                const relatedOwner_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProofPacket2 = await ProofPackets.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProofPacket2?.setOwner_user)
                {
                    await
                    ProofPacket2.
                    setOwner_user(relatedOwner_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
        
            
            async function associateRemediationItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setOrganization)
                {
                    await
                    RemediationItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setOrganization)
                {
                    await
                    RemediationItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setOrganization)
                {
                    await
                    RemediationItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateRemediationItemWithLinked_workflow() {
            
                const relatedLinked_workflow0 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setLinked_workflow)
                {
                    await
                    RemediationItem0.
                    setLinked_workflow(relatedLinked_workflow0);
                }
            
                const relatedLinked_workflow1 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setLinked_workflow)
                {
                    await
                    RemediationItem1.
                    setLinked_workflow(relatedLinked_workflow1);
                }
            
                const relatedLinked_workflow2 = await IdentityWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await IdentityWorkflows.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setLinked_workflow)
                {
                    await
                    RemediationItem2.
                    setLinked_workflow(relatedLinked_workflow2);
                }
            
        }
        
    
        
            
            async function associateRemediationItemWithLinked_control_requirement() {
            
                const relatedLinked_control_requirement0 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setLinked_control_requirement)
                {
                    await
                    RemediationItem0.
                    setLinked_control_requirement(relatedLinked_control_requirement0);
                }
            
                const relatedLinked_control_requirement1 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setLinked_control_requirement)
                {
                    await
                    RemediationItem1.
                    setLinked_control_requirement(relatedLinked_control_requirement1);
                }
            
                const relatedLinked_control_requirement2 = await ControlRequirements.findOne({
                    offset: Math.floor(Math.random() * (await ControlRequirements.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setLinked_control_requirement)
                {
                    await
                    RemediationItem2.
                    setLinked_control_requirement(relatedLinked_control_requirement2);
                }
            
        }
        
    
        
            
            async function associateRemediationItemWithLinked_artifact() {
            
                const relatedLinked_artifact0 = await Artifacts.findOne({
                    offset: Math.floor(Math.random() * (await Artifacts.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setLinked_artifact)
                {
                    await
                    RemediationItem0.
                    setLinked_artifact(relatedLinked_artifact0);
                }
            
                const relatedLinked_artifact1 = await Artifacts.findOne({
                    offset: Math.floor(Math.random() * (await Artifacts.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setLinked_artifact)
                {
                    await
                    RemediationItem1.
                    setLinked_artifact(relatedLinked_artifact1);
                }
            
                const relatedLinked_artifact2 = await Artifacts.findOne({
                    offset: Math.floor(Math.random() * (await Artifacts.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setLinked_artifact)
                {
                    await
                    RemediationItem2.
                    setLinked_artifact(relatedLinked_artifact2);
                }
            
        }
        
    
        
            
            async function associateRemediationItemWithLinked_packet() {
            
                const relatedLinked_packet0 = await ProofPackets.findOne({
                    offset: Math.floor(Math.random() * (await ProofPackets.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setLinked_packet)
                {
                    await
                    RemediationItem0.
                    setLinked_packet(relatedLinked_packet0);
                }
            
                const relatedLinked_packet1 = await ProofPackets.findOne({
                    offset: Math.floor(Math.random() * (await ProofPackets.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setLinked_packet)
                {
                    await
                    RemediationItem1.
                    setLinked_packet(relatedLinked_packet1);
                }
            
                const relatedLinked_packet2 = await ProofPackets.findOne({
                    offset: Math.floor(Math.random() * (await ProofPackets.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setLinked_packet)
                {
                    await
                    RemediationItem2.
                    setLinked_packet(relatedLinked_packet2);
                }
            
        }
        
    
        
            
            async function associateRemediationItemWithOwner_user() {
            
                const relatedOwner_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RemediationItem0 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RemediationItem0?.setOwner_user)
                {
                    await
                    RemediationItem0.
                    setOwner_user(relatedOwner_user0);
                }
            
                const relatedOwner_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RemediationItem1 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RemediationItem1?.setOwner_user)
                {
                    await
                    RemediationItem1.
                    setOwner_user(relatedOwner_user1);
                }
            
                const relatedOwner_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RemediationItem2 = await RemediationItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RemediationItem2?.setOwner_user)
                {
                    await
                    RemediationItem2.
                    setOwner_user(relatedOwner_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateAccessReviewWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReview0 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AccessReview0?.setOrganization)
                {
                    await
                    AccessReview0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReview1 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AccessReview1?.setOrganization)
                {
                    await
                    AccessReview1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReview2 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AccessReview2?.setOrganization)
                {
                    await
                    AccessReview2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateAccessReviewWithReviewer_user() {
            
                const relatedReviewer_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AccessReview0 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AccessReview0?.setReviewer_user)
                {
                    await
                    AccessReview0.
                    setReviewer_user(relatedReviewer_user0);
                }
            
                const relatedReviewer_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AccessReview1 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AccessReview1?.setReviewer_user)
                {
                    await
                    AccessReview1.
                    setReviewer_user(relatedReviewer_user1);
                }
            
                const relatedReviewer_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AccessReview2 = await AccessReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AccessReview2?.setReviewer_user)
                {
                    await
                    AccessReview2.
                    setReviewer_user(relatedReviewer_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateAccessReviewItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReviewItem0 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AccessReviewItem0?.setOrganization)
                {
                    await
                    AccessReviewItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReviewItem1 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AccessReviewItem1?.setOrganization)
                {
                    await
                    AccessReviewItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AccessReviewItem2 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AccessReviewItem2?.setOrganization)
                {
                    await
                    AccessReviewItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
            
            async function associateAccessReviewItemWithAccess_review() {
            
                const relatedAccess_review0 = await AccessReviews.findOne({
                    offset: Math.floor(Math.random() * (await AccessReviews.count())),
                });
                const AccessReviewItem0 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AccessReviewItem0?.setAccess_review)
                {
                    await
                    AccessReviewItem0.
                    setAccess_review(relatedAccess_review0);
                }
            
                const relatedAccess_review1 = await AccessReviews.findOne({
                    offset: Math.floor(Math.random() * (await AccessReviews.count())),
                });
                const AccessReviewItem1 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AccessReviewItem1?.setAccess_review)
                {
                    await
                    AccessReviewItem1.
                    setAccess_review(relatedAccess_review1);
                }
            
                const relatedAccess_review2 = await AccessReviews.findOne({
                    offset: Math.floor(Math.random() * (await AccessReviews.count())),
                });
                const AccessReviewItem2 = await AccessReviewItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AccessReviewItem2?.setAccess_review)
                {
                    await
                    AccessReviewItem2.
                    setAccess_review(relatedAccess_review2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateExceptionWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Exception0 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Exception0?.setOrganization)
                {
                    await
                    Exception0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Exception1 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Exception1?.setOrganization)
                {
                    await
                    Exception1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Exception2 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Exception2?.setOrganization)
                {
                    await
                    Exception2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateExceptionWithApprover_user() {
            
                const relatedApprover_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Exception0 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Exception0?.setApprover_user)
                {
                    await
                    Exception0.
                    setApprover_user(relatedApprover_user0);
                }
            
                const relatedApprover_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Exception1 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Exception1?.setApprover_user)
                {
                    await
                    Exception1.
                    setApprover_user(relatedApprover_user1);
                }
            
                const relatedApprover_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Exception2 = await Exceptions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Exception2?.setApprover_user)
                {
                    await
                    Exception2.
                    setApprover_user(relatedApprover_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
    

    
    
    
        
            
            async function associateAuditLogWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditLog0 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditLog0?.setOrganization)
                {
                    await
                    AuditLog0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditLog1 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditLog1?.setOrganization)
                {
                    await
                    AuditLog1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditLog2 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditLog2?.setOrganization)
                {
                    await
                    AuditLog2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
            
            async function associateAuditLogWithActor_user() {
            
                const relatedActor_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog0 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditLog0?.setActor_user)
                {
                    await
                    AuditLog0.
                    setActor_user(relatedActor_user0);
                }
            
                const relatedActor_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog1 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditLog1?.setActor_user)
                {
                    await
                    AuditLog1.
                    setActor_user(relatedActor_user1);
                }
            
                const relatedActor_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog2 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditLog2?.setActor_user)
                {
                    await
                    AuditLog2.
                    setActor_user(relatedActor_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateNotificationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Notification0 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Notification0?.setOrganization)
                {
                    await
                    Notification0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Notification1 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Notification1?.setOrganization)
                {
                    await
                    Notification1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Notification2 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Notification2?.setOrganization)
                {
                    await
                    Notification2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
            
            async function associateNotificationWithRecipient_user() {
            
                const relatedRecipient_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Notification0 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Notification0?.setRecipient_user)
                {
                    await
                    Notification0.
                    setRecipient_user(relatedRecipient_user0);
                }
            
                const relatedRecipient_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Notification1 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Notification1?.setRecipient_user)
                {
                    await
                    Notification1.
                    setRecipient_user(relatedRecipient_user1);
                }
            
                const relatedRecipient_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Notification2 = await Notifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Notification2?.setRecipient_user)
                {
                    await
                    Notification2.
                    setRecipient_user(relatedRecipient_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateOrganizationSettingWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OrganizationSetting0 = await OrganizationSettings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OrganizationSetting0?.setOrganization)
                {
                    await
                    OrganizationSetting0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OrganizationSetting1 = await OrganizationSettings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OrganizationSetting1?.setOrganization)
                {
                    await
                    OrganizationSetting1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OrganizationSetting2 = await OrganizationSettings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OrganizationSetting2?.setOrganization)
                {
                    await
                    OrganizationSetting2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateArtifactTypeCatalogWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ArtifactTypeCatalog0 = await ArtifactTypeCatalog.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ArtifactTypeCatalog0?.setOrganization)
                {
                    await
                    ArtifactTypeCatalog0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ArtifactTypeCatalog1 = await ArtifactTypeCatalog.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ArtifactTypeCatalog1?.setOrganization)
                {
                    await
                    ArtifactTypeCatalog1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ArtifactTypeCatalog2 = await ArtifactTypeCatalog.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ArtifactTypeCatalog2?.setOrganization)
                {
                    await
                    ArtifactTypeCatalog2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateWorkflowTemplateWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const WorkflowTemplate0 = await WorkflowTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkflowTemplate0?.setOrganization)
                {
                    await
                    WorkflowTemplate0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const WorkflowTemplate1 = await WorkflowTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkflowTemplate1?.setOrganization)
                {
                    await
                    WorkflowTemplate1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const WorkflowTemplate2 = await WorkflowTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkflowTemplate2?.setOrganization)
                {
                    await
                    WorkflowTemplate2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Organizations.bulkCreate(OrganizationsData);
                
            
            
                
                await UserInvitations.bulkCreate(UserInvitationsData);
                
            
            
                
                await ConnectedSystems.bulkCreate(ConnectedSystemsData);
                
            
            
                
                await ControlFrameworks.bulkCreate(ControlFrameworksData);
                
            
            
                
                await ControlRequirements.bulkCreate(ControlRequirementsData);
                
            
            
                
                await IdentityWorkflows.bulkCreate(IdentityWorkflowsData);
                
            
            
                
                await EvidenceModels.bulkCreate(EvidenceModelsData);
                
            
            
                
                await Artifacts.bulkCreate(ArtifactsData);
                
            
            
                
                await SampledSubjects.bulkCreate(SampledSubjectsData);
                
            
            
                
                await ProofPackets.bulkCreate(ProofPacketsData);
                
            
            
                
                await RemediationItems.bulkCreate(RemediationItemsData);
                
            
            
                
                await AccessReviews.bulkCreate(AccessReviewsData);
                
            
            
                
                await AccessReviewItems.bulkCreate(AccessReviewItemsData);
                
            
            
                
                await Exceptions.bulkCreate(ExceptionsData);
                
            
            
                
                await AuditLogs.bulkCreate(AuditLogsData);
                
            
            
                
                await Notifications.bulkCreate(NotificationsData);
                
            
            
                
                await OrganizationSettings.bulkCreate(OrganizationSettingsData);
                
            
            
                
                await ArtifactTypeCatalog.bulkCreate(ArtifactTypeCatalogData);
                
            
            
                
                await WorkflowTemplates.bulkCreate(WorkflowTemplatesData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateUserWithOrganization(),
                    
                
            
                
                
                
                
                    
                
            
                
                
                    
                        
                        await associateUserInvitationWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateUserInvitationWithInvited_by_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateConnectedSystemWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateControlFrameworkWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateControlRequirementWithFramework(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateControlRequirementWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateIdentityWorkflowWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                    
                        
                        await associateEvidenceModelWithOrganization(),
                    
                
                    
                        
                        await associateEvidenceModelWithWorkflow(),
                    
                
                    
                        
                        await associateEvidenceModelWithControl_requirement(),
                    
                
                    
                
                    
                        
                        await associateEvidenceModelWithSource_system(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateArtifactWithOrganization(),
                    
                
                    
                        
                        await associateArtifactWithWorkflow(),
                    
                
                    
                        
                        await associateArtifactWithEvidence_model(),
                    
                
                    
                        
                        await associateArtifactWithSource_system(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateArtifactWithCollected_by_user(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateArtifactWithApprover_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateSampledSubjectWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSampledSubjectWithWorkflow(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateProofPacketWithOrganization(),
                    
                
                    
                
                    
                
                    
                        
                        await associateProofPacketWithFramework(),
                    
                
                    
                        
                        await associateProofPacketWithWorkflow(),
                    
                
                    
                        
                        await associateProofPacketWithSampled_subject(),
                    
                
                    
                        
                        await associateProofPacketWithOwner_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                    
                        
                        await associateRemediationItemWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateRemediationItemWithLinked_workflow(),
                    
                
                    
                        
                        await associateRemediationItemWithLinked_control_requirement(),
                    
                
                    
                        
                        await associateRemediationItemWithLinked_artifact(),
                    
                
                    
                        
                        await associateRemediationItemWithLinked_packet(),
                    
                
                    
                        
                        await associateRemediationItemWithOwner_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateAccessReviewWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateAccessReviewWithReviewer_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateAccessReviewItemWithOrganization(),
                    
                
                    
                        
                        await associateAccessReviewItemWithAccess_review(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateExceptionWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateExceptionWithApprover_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                
            
                
                
                    
                        
                        await associateAuditLogWithOrganization(),
                    
                
                    
                        
                        await associateAuditLogWithActor_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateNotificationWithOrganization(),
                    
                
                    
                        
                        await associateNotificationWithRecipient_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateOrganizationSettingWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateArtifactTypeCatalogWithOrganization(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateWorkflowTemplateWithOrganization(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('organizations', null, {});
            
            
            await queryInterface.bulkDelete('user_invitations', null, {});
            
            
            await queryInterface.bulkDelete('connected_systems', null, {});
            
            
            await queryInterface.bulkDelete('control_frameworks', null, {});
            
            
            await queryInterface.bulkDelete('control_requirements', null, {});
            
            
            await queryInterface.bulkDelete('identity_workflows', null, {});
            
            
            await queryInterface.bulkDelete('evidence_models', null, {});
            
            
            await queryInterface.bulkDelete('artifacts', null, {});
            
            
            await queryInterface.bulkDelete('sampled_subjects', null, {});
            
            
            await queryInterface.bulkDelete('proof_packets', null, {});
            
            
            await queryInterface.bulkDelete('remediation_items', null, {});
            
            
            await queryInterface.bulkDelete('access_reviews', null, {});
            
            
            await queryInterface.bulkDelete('access_review_items', null, {});
            
            
            await queryInterface.bulkDelete('exceptions', null, {});
            
            
            await queryInterface.bulkDelete('audit_logs', null, {});
            
            
            await queryInterface.bulkDelete('notifications', null, {});
            
            
            await queryInterface.bulkDelete('organization_settings', null, {});
            
            
            await queryInterface.bulkDelete('artifact_type_catalog', null, {});
            
            
            await queryInterface.bulkDelete('workflow_templates', null, {});
            
        
    },
};