const db = require('../models'); const Users = db.users; const Events = db.events; const Venues = db.venues; const Vendors = db.vendors; const EventVendors = db.event_vendors; const Tasks = db.tasks; const ScheduleItems = db.schedule_items; const Guests = db.guests; const BudgetItems = db.budget_items; const ActivityLogs = db.activity_logs; const EventsData = [ { "name": "Q2 Product Launch Summit", "event_type": "conference", "status": "planning", "start_at": new Date('2026-04-14T09:00:00Z'), "end_at": new Date('2026-04-14T18:00:00Z'), "location_name": "San Francisco, CA", "expected_guest_count": 420, "budget_total_planned": 85000.0, "budget_total_actual": 0.0, // type code here for "relation_one" field // type code here for "relation_one" field "notes": "One-day summit with keynote, demos, and customer panels.", // type code here for "files" field }, { "name": "Customer Advisory Board Dinner", "event_type": "internal", "status": "confirmed", "start_at": new Date('2026-03-05T19:00:00Z'), "end_at": new Date('2026-03-05T22:00:00Z'), "location_name": "San Francisco, CA", "expected_guest_count": 40, "budget_total_planned": 15000.0, "budget_total_actual": 0.0, // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Private dinner with executives. Confirm dietary needs and seating plan.", // type code here for "files" field }, { "name": "New Hire Orientation Week", "event_type": "client", "status": "draft", "start_at": new Date('2026-02-24T16:00:00Z'), "end_at": new Date('2026-02-28T01:00:00Z'), "location_name": "San Mateo, CA", "expected_guest_count": 55, "budget_total_planned": 12000.0, "budget_total_actual": 0.0, // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Mix of sessions, facilities tour, and social activities.", // type code here for "files" field }, { "name": "Internal Ops All-Hands", "event_type": "training", "status": "completed", "start_at": new Date('2026-05-20T17:00:00Z'), "end_at": new Date('2026-05-20T19:00:00Z'), "location_name": "San Jose, CA", "expected_guest_count": 650, "budget_total_planned": 40000.0, "budget_total_actual": 0.0, // type code here for "relation_one" field // type code here for "relation_one" field "notes": "All-hands with leadership updates. Confirm venue availability and AV.", // type code here for "files" field }, ]; const VenuesData = [ { "name": "Harborview Conference Center", "venue_type": "hotel", "status": "hold", "address_line_1": "200 Bayfront Ave", "address_line_2": "Suite 100", "city": "San Francisco", "state_region": "CA", "postal_code": "94105", "country": "USA", "capacity": 600, "base_rate": 25000.0, "contact_name": "Elena Ramirez", "contact_email": "elena.ramirez@harborviewcc.example", "contact_phone": "+1-415-555-0201", "website_url": "https://harborviewcc.example", "notes": "Main ballroom plus 4 breakout rooms. Loading dock access available.", // type code here for "files" field }, { "name": "Redwood Hotel Downtown", "venue_type": "conference_center", "status": "cancelled", "address_line_1": "88 Market Street", "address_line_2": "Floor 2 Events", "city": "San Francisco", "state_region": "CA", "postal_code": "94105", "country": "USA", "capacity": 350, "base_rate": 18000.0, "contact_name": "Marcus Hill", "contact_email": "marcus.hill@redwoodhotel.example", "contact_phone": "+1-415-555-0202", "website_url": "https://redwoodhotel.example", "notes": "Preferred dates on hold. Catering minimum applies.", // type code here for "files" field }, { "name": "Mission Terrace Garden", "venue_type": "outdoor", "status": "contacted", "address_line_1": "455 Terrace Blvd", "address_line_2": "Gate B", "city": "San Francisco", "state_region": "CA", "postal_code": "94110", "country": "USA", "capacity": 200, "base_rate": 9500.0, "contact_name": "Sofia Chen", "contact_email": "sofia.chen@missionterrace.example", "contact_phone": "+1-415-555-0203", "website_url": "https://missionterrace.example", "notes": "Outdoor space with strict sound ordinance after 9 PM.", // type code here for "files" field }, { "name": "Civic Auditorium Annex", "venue_type": "hotel", "status": "prospect", "address_line_1": "10 Civic Plaza", "address_line_2": "Annex Entrance", "city": "San Jose", "state_region": "CA", "postal_code": "95113", "country": "USA", "capacity": 900, "base_rate": 32000.0, "contact_name": "Derek Nguyen", "contact_email": "derek.nguyen@civicauditorium.example", "contact_phone": "+1-408-555-0204", "website_url": "https://civicauditorium.example", "notes": "Large capacity ideal for all-hands. AV must use in-house provider.", // type code here for "files" field }, ]; const VendorsData = [ { "name": "Golden Gate Catering Co.", "category": "decor", "status": "cancelled", "contact_name": "Renee Walker", "contact_email": "renee.walker@ggcatering.example", "contact_phone": "+1-415-555-0301", "website_url": "https://ggcatering.example", "default_rate": 75.0, "preferred": true, "notes": "Strong vegetarian options. Can accommodate allergens with advance notice.", // type code here for "files" field }, { "name": "Pulse AV Services", "category": "catering", "status": "contacted", "contact_name": "Samir Qureshi", "contact_email": "samir.qureshi@pulseav.example", "contact_phone": "+1-415-555-0302", "website_url": "https://pulseav.example", "default_rate": 12000.0, "preferred": true, "notes": "Quote includes stage wash lighting and 4 wireless mics.", // type code here for "files" field }, { "name": "Evergreen Decor Studio", "category": "security", "status": "contacted", "contact_name": "Lily Park", "contact_email": "lily.park@evergreendecor.example", "contact_phone": "+1-415-555-0303", "website_url": "https://evergreendecor.example", "default_rate": 6500.0, "preferred": true, "notes": "Specializes in modern florals and minimal stage design.", // type code here for "files" field }, { "name": "CitySafe Security", "category": "staffing", "status": "cancelled", "contact_name": "Owen Brooks", "contact_email": "owen.brooks@citysafe.example", "contact_phone": "+1-415-555-0304", "website_url": "https://citysafe.example", "default_rate": 45.0, "preferred": true, "notes": "Can provide badge checks and overnight equipment watch.", // type code here for "files" field }, ]; const EventVendorsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "status": "confirmed", // type code here for "relation_one" field "planned_cost": 31500.0, "actual_cost": 0.0, "contract_due_at": new Date('2026-03-10T17:00:00Z'), "service_start_at": new Date('2026-04-14T15:00:00Z'), "service_end_at": new Date('2026-04-14T23:00:00Z'), "scope": "Breakfast, lunch, and afternoon reception. Include labeled allergens and vegan options.", // type code here for "files" field }, { // type code here for "relation_one" field // type code here for "relation_one" field "status": "completed", // type code here for "relation_one" field "planned_cost": 14500.0, "actual_cost": 0.0, "contract_due_at": new Date('2026-03-20T17:00:00Z'), "service_start_at": new Date('2026-04-14T14:00:00Z'), "service_end_at": new Date('2026-04-15T02:00:00Z'), "scope": "Stage, sound, lighting, two confidence monitors, and livestream recording.", // type code here for "files" field }, { // type code here for "relation_one" field // type code here for "relation_one" field "status": "cancelled", // type code here for "relation_one" field "planned_cost": 7800.0, "actual_cost": 0.0, "contract_due_at": new Date('2026-02-10T17:00:00Z'), "service_start_at": new Date('2026-03-05T18:00:00Z'), "service_end_at": new Date('2026-03-05T23:30:00Z'), "scope": "Plated dinner with wine pairings. Confirm final headcount 7 days prior.", // type code here for "files" field }, { // type code here for "relation_one" field // type code here for "relation_one" field "status": "in_progress", // type code here for "relation_one" field "planned_cost": 4200.0, "actual_cost": 0.0, "contract_due_at": new Date('2026-05-15T17:00:00Z'), "service_start_at": new Date('2026-06-10T14:00:00Z'), "service_end_at": new Date('2026-06-10T18:00:00Z'), "scope": "Minimal stage florals and registration table arrangement.", // type code here for "files" field }, ]; const TasksData = [ { // type code here for "relation_one" field "type": "task", "status": "in_progress", "title": "Finalize venue floorplan", "description": "Confirm seating layout, stage placement, and breakout room assignments with venue.", // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "due_at": new Date('2026-03-15T17:00:00Z'), "start_at": new Date('2026-03-01T17:00:00Z'), "completed_at": new Date('2020-01-01T00:00:00Z'), "priority": 1, "requires_approval": true, // type code here for "files" field }, { // type code here for "relation_one" field "type": "milestone", "status": "cancelled", "title": "Send speaker briefing packet", "description": "Provide run-of-show, arrival times, and slide guidelines to all speakers.", // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "due_at": new Date('2026-03-25T17:00:00Z'), "start_at": new Date('2026-03-20T17:00:00Z'), "completed_at": new Date('2020-01-01T00:00:00Z'), "priority": 2, "requires_approval": false, // type code here for "files" field }, { // type code here for "relation_one" field "type": "milestone", "status": "in_progress", "title": "Confirm menu and dietary needs", "description": "Collect dietary requirements and confirm final menu with catering.", // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "due_at": new Date('2026-02-20T17:00:00Z'), "start_at": new Date('2026-02-12T17:00:00Z'), "completed_at": new Date('2020-01-01T00:00:00Z'), "priority": 1, "requires_approval": false, // type code here for "files" field }, { // type code here for "relation_one" field "type": "review", "status": "cancelled", "title": "Compile badge access list", "description": "Send attendee list to facilities for building access and Wi-Fi provisioning.", // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "due_at": new Date('2026-02-18T20:00:00Z'), "start_at": new Date('2026-02-10T18:00:00Z'), "completed_at": new Date('2020-01-01T00:00:00Z'), "priority": 1, "requires_approval": true, // type code here for "files" field }, ]; const ScheduleItemsData = [ { // type code here for "relation_one" field "title": "Registration and coffee", "description": "Check-in opens. Coffee and light breakfast available in pre-function area.", "category": "setup", "start_at": new Date('2026-04-14T15:00:00Z'), "end_at": new Date('2026-04-14T16:00:00Z'), // 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 "title": "Keynote", "description": "Opening keynote with product vision and roadmap highlights.", "category": "teardown", "start_at": new Date('2026-04-14T16:00:00Z'), "end_at": new Date('2026-04-14T16:45:00Z'), // 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 "title": "Lunch", "description": "Buffet lunch with labeled dietary options.", "category": "session", "start_at": new Date('2026-04-14T19:15:00Z'), "end_at": new Date('2026-04-14T20:15:00Z'), // 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 "title": "Welcome reception", "description": "Cocktails and networking before dinner seating.", "category": "teardown", "start_at": new Date('2026-03-05T19:00:00Z'), "end_at": new Date('2026-03-05T19:30:00Z'), // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field }, ]; const GuestsData = [ { // type code here for "relation_one" field "full_name": "Taylor Morgan", "email": "taylor.morgan@northwind.example", "phone": "+1-212-555-0111", "company": "Northwind Systems", "title": "Director of Engineering", "invitation_status": "not_sent", "rsvp_status": "no", "invited_at": new Date('2026-02-20T18:00:00Z'), "responded_at": new Date('2026-02-23T16:10:00Z'), "party_size": 1, "dietary_preference": "gluten_free", "vip": true, "notes": "VIP seating requested near aisle.", }, { // type code here for "relation_one" field "full_name": "Casey Rivera", "email": "casey.rivera@contoso.example", "phone": "+1-206-555-0109", "company": "Contoso", "title": "Product Manager", "invitation_status": "bounced", "rsvp_status": "yes", "invited_at": new Date('2026-02-20T18:00:00Z'), "responded_at": new Date('2020-01-01T00:00:00Z'), "party_size": 1, "dietary_preference": "kosher", "vip": false, "notes": "Follow up one week before event if no response.", }, { // type code here for "relation_one" field "full_name": "Morgan Chen", "email": "morgan.chen@fabrikam.example", "phone": "+1-312-555-0199", "company": "Fabrikam", "title": "VP Operations", "invitation_status": "cancelled", "rsvp_status": "maybe", "invited_at": new Date('2026-01-28T18:00:00Z'), "responded_at": new Date('2026-01-30T15:45:00Z'), "party_size": 2, "dietary_preference": "vegetarian", "vip": true, "notes": "Requires gluten-free options for both attendees.", }, { // type code here for "relation_one" field "full_name": "Jamie Patel", "email": "jamie.patel@acme-events.local", "phone": "+1-650-555-0133", "company": "Acme", "title": "Software Engineer", "invitation_status": "sent", "rsvp_status": "maybe", "invited_at": new Date('2026-02-01T18:00:00Z'), "responded_at": new Date('2026-02-02T17:20:00Z'), "party_size": 1, "dietary_preference": "other", "vip": false, "notes": "Needs Wi-Fi access for laptop on day one.", }, ]; const BudgetItemsData = [ { // type code here for "relation_one" field "category": "venue", "name": "Venue rental and service charges", "status": "planned", "planned_amount": 28000.0, "actual_amount": 0.0, "due_at": new Date('2026-03-30T17:00:00Z'), "paid_at": new Date('2020-01-01T00:00:00Z'), // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Includes ballroom, breakout rooms, and standard service fees.", // type code here for "files" field }, { // type code here for "relation_one" field "category": "other", "name": "Food and beverage package", "status": "committed", "planned_amount": 31500.0, "actual_amount": 0.0, "due_at": new Date('2026-04-10T17:00:00Z'), "paid_at": new Date('2020-01-01T00:00:00Z'), // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Estimated for 420 attendees. Final invoice after actual headcount.", // type code here for "files" field }, { // type code here for "relation_one" field "category": "software", "name": "AV production", "status": "planned", "planned_amount": 14500.0, "actual_amount": 0.0, "due_at": new Date('2026-04-05T17:00:00Z'), "paid_at": new Date('2020-01-01T00:00:00Z'), // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Pending final scope confirmation and approval.", // type code here for "files" field }, { // type code here for "relation_one" field "category": "decor", "name": "Dinner catering", "status": "planned", "planned_amount": 7800.0, "actual_amount": 0.0, "due_at": new Date('2026-03-01T17:00:00Z'), "paid_at": new Date('2020-01-01T00:00:00Z'), // type code here for "relation_one" field // type code here for "relation_one" field "notes": "Includes service staff and rentals per hotel requirements.", // type code here for "files" field }, ]; const ActivityLogsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "action": "commented", "entity_name": "events", "entity_label": "Q2 Product Launch Summit", "message": "Event created and initial budget drafted.", "occurred_at": new Date('2026-02-18T16:30:00Z'), }, { // type code here for "relation_one" field // type code here for "relation_one" field "action": "created", "entity_name": "event_vendors", "entity_label": "Pulse AV Services booking", "message": "Vendor booking moved to in_progress pending final scope.", "occurred_at": new Date('2026-02-25T18:10:00Z'), }, { // type code here for "relation_one" field // type code here for "relation_one" field "action": "completed", "entity_name": "events", "entity_label": "Customer Advisory Board Dinner", "message": "Updated expected guest count and added notes for seating plan.", "occurred_at": new Date('2026-02-02T17:05:00Z'), }, { // type code here for "relation_one" field // type code here for "relation_one" field "action": "updated", "entity_name": "tasks", "entity_label": "Compile badge access list", "message": "Task assigned to coordinator for facilities submission.", "occurred_at": new Date('2026-02-10T18:05:00Z'), }, ]; // Similar logic for "relation_many" async function associateEventWithPrimary_venue() { const relatedPrimary_venue0 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Event0 = await Events.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Event0?.setPrimary_venue) { await Event0. setPrimary_venue(relatedPrimary_venue0); } const relatedPrimary_venue1 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Event1 = await Events.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Event1?.setPrimary_venue) { await Event1. setPrimary_venue(relatedPrimary_venue1); } const relatedPrimary_venue2 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Event2 = await Events.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Event2?.setPrimary_venue) { await Event2. setPrimary_venue(relatedPrimary_venue2); } const relatedPrimary_venue3 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Event3 = await Events.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Event3?.setPrimary_venue) { await Event3. setPrimary_venue(relatedPrimary_venue3); } } async function associateEventWithOwner() { const relatedOwner0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Event0 = await Events.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Event0?.setOwner) { await Event0. setOwner(relatedOwner0); } const relatedOwner1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Event1 = await Events.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Event1?.setOwner) { await Event1. setOwner(relatedOwner1); } const relatedOwner2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Event2 = await Events.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Event2?.setOwner) { await Event2. setOwner(relatedOwner2); } const relatedOwner3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Event3 = await Events.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Event3?.setOwner) { await Event3. setOwner(relatedOwner3); } } async function associateEventVendorWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const EventVendor0 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 0 }); if (EventVendor0?.setEvent) { await EventVendor0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const EventVendor1 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 1 }); if (EventVendor1?.setEvent) { await EventVendor1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const EventVendor2 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 2 }); if (EventVendor2?.setEvent) { await EventVendor2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const EventVendor3 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 3 }); if (EventVendor3?.setEvent) { await EventVendor3. setEvent(relatedEvent3); } } async function associateEventVendorWithVendor() { const relatedVendor0 = await Vendors.findOne({ offset: Math.floor(Math.random() * (await Vendors.count())), }); const EventVendor0 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 0 }); if (EventVendor0?.setVendor) { await EventVendor0. setVendor(relatedVendor0); } const relatedVendor1 = await Vendors.findOne({ offset: Math.floor(Math.random() * (await Vendors.count())), }); const EventVendor1 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 1 }); if (EventVendor1?.setVendor) { await EventVendor1. setVendor(relatedVendor1); } const relatedVendor2 = await Vendors.findOne({ offset: Math.floor(Math.random() * (await Vendors.count())), }); const EventVendor2 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 2 }); if (EventVendor2?.setVendor) { await EventVendor2. setVendor(relatedVendor2); } const relatedVendor3 = await Vendors.findOne({ offset: Math.floor(Math.random() * (await Vendors.count())), }); const EventVendor3 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 3 }); if (EventVendor3?.setVendor) { await EventVendor3. setVendor(relatedVendor3); } } async function associateEventVendorWithOwner() { const relatedOwner0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const EventVendor0 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 0 }); if (EventVendor0?.setOwner) { await EventVendor0. setOwner(relatedOwner0); } const relatedOwner1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const EventVendor1 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 1 }); if (EventVendor1?.setOwner) { await EventVendor1. setOwner(relatedOwner1); } const relatedOwner2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const EventVendor2 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 2 }); if (EventVendor2?.setOwner) { await EventVendor2. setOwner(relatedOwner2); } const relatedOwner3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const EventVendor3 = await EventVendors.findOne({ order: [['id', 'ASC']], offset: 3 }); if (EventVendor3?.setOwner) { await EventVendor3. setOwner(relatedOwner3); } } async function associateTaskWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Task0 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Task0?.setEvent) { await Task0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Task1 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Task1?.setEvent) { await Task1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Task2 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Task2?.setEvent) { await Task2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Task3 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Task3?.setEvent) { await Task3. setEvent(relatedEvent3); } } async function associateTaskWithAssignee() { const relatedAssignee0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Task0 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Task0?.setAssignee) { await Task0. setAssignee(relatedAssignee0); } const relatedAssignee1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Task1 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Task1?.setAssignee) { await Task1. setAssignee(relatedAssignee1); } const relatedAssignee2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Task2 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Task2?.setAssignee) { await Task2. setAssignee(relatedAssignee2); } const relatedAssignee3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Task3 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Task3?.setAssignee) { await Task3. setAssignee(relatedAssignee3); } } async function associateTaskWithRelated_vendor_booking() { const relatedRelated_vendor_booking0 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const Task0 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Task0?.setRelated_vendor_booking) { await Task0. setRelated_vendor_booking(relatedRelated_vendor_booking0); } const relatedRelated_vendor_booking1 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const Task1 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Task1?.setRelated_vendor_booking) { await Task1. setRelated_vendor_booking(relatedRelated_vendor_booking1); } const relatedRelated_vendor_booking2 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const Task2 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Task2?.setRelated_vendor_booking) { await Task2. setRelated_vendor_booking(relatedRelated_vendor_booking2); } const relatedRelated_vendor_booking3 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const Task3 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Task3?.setRelated_vendor_booking) { await Task3. setRelated_vendor_booking(relatedRelated_vendor_booking3); } } async function associateTaskWithRelated_venue() { const relatedRelated_venue0 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Task0 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Task0?.setRelated_venue) { await Task0. setRelated_venue(relatedRelated_venue0); } const relatedRelated_venue1 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Task1 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Task1?.setRelated_venue) { await Task1. setRelated_venue(relatedRelated_venue1); } const relatedRelated_venue2 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Task2 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Task2?.setRelated_venue) { await Task2. setRelated_venue(relatedRelated_venue2); } const relatedRelated_venue3 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const Task3 = await Tasks.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Task3?.setRelated_venue) { await Task3. setRelated_venue(relatedRelated_venue3); } } async function associateScheduleItemWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ScheduleItem0 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ScheduleItem0?.setEvent) { await ScheduleItem0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ScheduleItem1 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ScheduleItem1?.setEvent) { await ScheduleItem1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ScheduleItem2 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ScheduleItem2?.setEvent) { await ScheduleItem2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ScheduleItem3 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ScheduleItem3?.setEvent) { await ScheduleItem3. setEvent(relatedEvent3); } } async function associateScheduleItemWithOwner() { const relatedOwner0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ScheduleItem0 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ScheduleItem0?.setOwner) { await ScheduleItem0. setOwner(relatedOwner0); } const relatedOwner1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ScheduleItem1 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ScheduleItem1?.setOwner) { await ScheduleItem1. setOwner(relatedOwner1); } const relatedOwner2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ScheduleItem2 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ScheduleItem2?.setOwner) { await ScheduleItem2. setOwner(relatedOwner2); } const relatedOwner3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ScheduleItem3 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ScheduleItem3?.setOwner) { await ScheduleItem3. setOwner(relatedOwner3); } } async function associateScheduleItemWithVenue() { const relatedVenue0 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const ScheduleItem0 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ScheduleItem0?.setVenue) { await ScheduleItem0. setVenue(relatedVenue0); } const relatedVenue1 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const ScheduleItem1 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ScheduleItem1?.setVenue) { await ScheduleItem1. setVenue(relatedVenue1); } const relatedVenue2 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const ScheduleItem2 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ScheduleItem2?.setVenue) { await ScheduleItem2. setVenue(relatedVenue2); } const relatedVenue3 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const ScheduleItem3 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ScheduleItem3?.setVenue) { await ScheduleItem3. setVenue(relatedVenue3); } } async function associateScheduleItemWithVendor_booking() { const relatedVendor_booking0 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const ScheduleItem0 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ScheduleItem0?.setVendor_booking) { await ScheduleItem0. setVendor_booking(relatedVendor_booking0); } const relatedVendor_booking1 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const ScheduleItem1 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ScheduleItem1?.setVendor_booking) { await ScheduleItem1. setVendor_booking(relatedVendor_booking1); } const relatedVendor_booking2 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const ScheduleItem2 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ScheduleItem2?.setVendor_booking) { await ScheduleItem2. setVendor_booking(relatedVendor_booking2); } const relatedVendor_booking3 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const ScheduleItem3 = await ScheduleItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ScheduleItem3?.setVendor_booking) { await ScheduleItem3. setVendor_booking(relatedVendor_booking3); } } async function associateGuestWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Guest0 = await Guests.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Guest0?.setEvent) { await Guest0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Guest1 = await Guests.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Guest1?.setEvent) { await Guest1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Guest2 = await Guests.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Guest2?.setEvent) { await Guest2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Guest3 = await Guests.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Guest3?.setEvent) { await Guest3. setEvent(relatedEvent3); } } async function associateBudgetItemWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const BudgetItem0 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (BudgetItem0?.setEvent) { await BudgetItem0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const BudgetItem1 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (BudgetItem1?.setEvent) { await BudgetItem1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const BudgetItem2 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (BudgetItem2?.setEvent) { await BudgetItem2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const BudgetItem3 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (BudgetItem3?.setEvent) { await BudgetItem3. setEvent(relatedEvent3); } } async function associateBudgetItemWithVendor_booking() { const relatedVendor_booking0 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const BudgetItem0 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (BudgetItem0?.setVendor_booking) { await BudgetItem0. setVendor_booking(relatedVendor_booking0); } const relatedVendor_booking1 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const BudgetItem1 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (BudgetItem1?.setVendor_booking) { await BudgetItem1. setVendor_booking(relatedVendor_booking1); } const relatedVendor_booking2 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const BudgetItem2 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (BudgetItem2?.setVendor_booking) { await BudgetItem2. setVendor_booking(relatedVendor_booking2); } const relatedVendor_booking3 = await EventVendors.findOne({ offset: Math.floor(Math.random() * (await EventVendors.count())), }); const BudgetItem3 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (BudgetItem3?.setVendor_booking) { await BudgetItem3. setVendor_booking(relatedVendor_booking3); } } async function associateBudgetItemWithVenue() { const relatedVenue0 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const BudgetItem0 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 0 }); if (BudgetItem0?.setVenue) { await BudgetItem0. setVenue(relatedVenue0); } const relatedVenue1 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const BudgetItem1 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 1 }); if (BudgetItem1?.setVenue) { await BudgetItem1. setVenue(relatedVenue1); } const relatedVenue2 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const BudgetItem2 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 2 }); if (BudgetItem2?.setVenue) { await BudgetItem2. setVenue(relatedVenue2); } const relatedVenue3 = await Venues.findOne({ offset: Math.floor(Math.random() * (await Venues.count())), }); const BudgetItem3 = await BudgetItems.findOne({ order: [['id', 'ASC']], offset: 3 }); if (BudgetItem3?.setVenue) { await BudgetItem3. setVenue(relatedVenue3); } } async function associateActivityLogWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ActivityLog0 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ActivityLog0?.setEvent) { await ActivityLog0. setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ActivityLog1 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ActivityLog1?.setEvent) { await ActivityLog1. setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ActivityLog2 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ActivityLog2?.setEvent) { await ActivityLog2. setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const ActivityLog3 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ActivityLog3?.setEvent) { await ActivityLog3. setEvent(relatedEvent3); } } async function associateActivityLogWithActor() { const relatedActor0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ActivityLog0 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ActivityLog0?.setActor) { await ActivityLog0. setActor(relatedActor0); } const relatedActor1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ActivityLog1 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ActivityLog1?.setActor) { await ActivityLog1. setActor(relatedActor1); } const relatedActor2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ActivityLog2 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ActivityLog2?.setActor) { await ActivityLog2. setActor(relatedActor2); } const relatedActor3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ActivityLog3 = await ActivityLogs.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ActivityLog3?.setActor) { await ActivityLog3. setActor(relatedActor3); } } module.exports = { up: async (queryInterface, Sequelize) => { await Events.bulkCreate(EventsData); await Venues.bulkCreate(VenuesData); await Vendors.bulkCreate(VendorsData); await EventVendors.bulkCreate(EventVendorsData); await Tasks.bulkCreate(TasksData); await ScheduleItems.bulkCreate(ScheduleItemsData); await Guests.bulkCreate(GuestsData); await BudgetItems.bulkCreate(BudgetItemsData); await ActivityLogs.bulkCreate(ActivityLogsData); await Promise.all([ // Similar logic for "relation_many" await associateEventWithPrimary_venue(), await associateEventWithOwner(), await associateEventVendorWithEvent(), await associateEventVendorWithVendor(), await associateEventVendorWithOwner(), await associateTaskWithEvent(), await associateTaskWithAssignee(), await associateTaskWithRelated_vendor_booking(), await associateTaskWithRelated_venue(), await associateScheduleItemWithEvent(), await associateScheduleItemWithOwner(), await associateScheduleItemWithVenue(), await associateScheduleItemWithVendor_booking(), await associateGuestWithEvent(), await associateBudgetItemWithEvent(), await associateBudgetItemWithVendor_booking(), await associateBudgetItemWithVenue(), await associateActivityLogWithEvent(), await associateActivityLogWithActor(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('events', null, {}); await queryInterface.bulkDelete('venues', null, {}); await queryInterface.bulkDelete('vendors', null, {}); await queryInterface.bulkDelete('event_vendors', null, {}); await queryInterface.bulkDelete('tasks', null, {}); await queryInterface.bulkDelete('schedule_items', null, {}); await queryInterface.bulkDelete('guests', null, {}); await queryInterface.bulkDelete('budget_items', null, {}); await queryInterface.bulkDelete('activity_logs', null, {}); }, };