39218-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-03-16 16:27:18 +00:00

6770 lines
131 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Venues = db.venues;
const Vendors = db.vendors;
const Events = db.events;
const EventTeamMembers = db.event_team_members;
const EventVendorBookings = db.event_vendor_bookings;
const ScheduleItems = db.schedule_items;
const Tasks = db.tasks;
const Guests = db.guests;
const Invitations = db.invitations;
const BudgetItems = db.budget_items;
const Communications = db.communications;
const VenuesData = [
{
"name": "Alan Turing",
"venue_type": "Alan Turing",
"address_line1": "Marie Curie",
"address_line2": "Alan Turing",
"city": "Alan Turing",
"state_region": "Alan Turing",
"postal_code": "Marie Curie",
"country": "Marie Curie",
"primary_contact_name": "Alan Turing",
"primary_contact_email": "Alan Turing",
"primary_contact_phone": "Alan Turing",
"capacity": 6,
"notes": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Marie Curie",
"venue_type": "Marie Curie",
"address_line1": "Ada Lovelace",
"address_line2": "Grace Hopper",
"city": "Alan Turing",
"state_region": "Alan Turing",
"postal_code": "Alan Turing",
"country": "Alan Turing",
"primary_contact_name": "Alan Turing",
"primary_contact_email": "Grace Hopper",
"primary_contact_phone": "Grace Hopper",
"capacity": 6,
"notes": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Marie Curie",
"venue_type": "Marie Curie",
"address_line1": "Ada Lovelace",
"address_line2": "Marie Curie",
"city": "Ada Lovelace",
"state_region": "Alan Turing",
"postal_code": "Ada Lovelace",
"country": "Alan Turing",
"primary_contact_name": "Marie Curie",
"primary_contact_email": "Ada Lovelace",
"primary_contact_phone": "Alan Turing",
"capacity": 4,
"notes": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Grace Hopper",
"venue_type": "Grace Hopper",
"address_line1": "Ada Lovelace",
"address_line2": "Grace Hopper",
"city": "Grace Hopper",
"state_region": "Marie Curie",
"postal_code": "Grace Hopper",
"country": "Marie Curie",
"primary_contact_name": "Ada Lovelace",
"primary_contact_email": "Ada Lovelace",
"primary_contact_phone": "Grace Hopper",
"capacity": 1,
"notes": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Grace Hopper",
"venue_type": "Marie Curie",
"address_line1": "Alan Turing",
"address_line2": "Marie Curie",
"city": "Alan Turing",
"state_region": "Ada Lovelace",
"postal_code": "Alan Turing",
"country": "Alan Turing",
"primary_contact_name": "Alan Turing",
"primary_contact_email": "Grace Hopper",
"primary_contact_phone": "Ada Lovelace",
"capacity": 7,
"notes": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
},
];
const VendorsData = [
{
"name": "Ada Lovelace",
"category": "entertainment",
"primary_contact_name": "Grace Hopper",
"primary_contact_email": "Ada Lovelace",
"primary_contact_phone": "Marie Curie",
"website": "Alan Turing",
"address": "Marie Curie",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
"name": "Alan Turing",
"category": "photography",
"primary_contact_name": "Ada Lovelace",
"primary_contact_email": "Ada Lovelace",
"primary_contact_phone": "Ada Lovelace",
"website": "Ada Lovelace",
"address": "Marie Curie",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
"name": "Grace Hopper",
"category": "rentals",
"primary_contact_name": "Ada Lovelace",
"primary_contact_email": "Marie Curie",
"primary_contact_phone": "Alan Turing",
"website": "Grace Hopper",
"address": "Alan Turing",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
"name": "Alan Turing",
"category": "entertainment",
"primary_contact_name": "Ada Lovelace",
"primary_contact_email": "Marie Curie",
"primary_contact_phone": "Alan Turing",
"website": "Ada Lovelace",
"address": "Grace Hopper",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
"name": "Ada Lovelace",
"category": "entertainment",
"primary_contact_name": "Ada Lovelace",
"primary_contact_email": "Ada Lovelace",
"primary_contact_phone": "Alan Turing",
"website": "Grace Hopper",
"address": "Ada Lovelace",
"notes": "Alan Turing",
// type code here for "files" field
},
];
const EventsData = [
{
"name": "Alan Turing",
"status": "in_progress",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
"timezone": "Alan Turing",
"description": "Alan Turing",
"expected_guests": 5,
"budget_total": 4.56,
"budget_spent": 2.08,
"budget_remaining": 3.61,
"internal_notes": "Ada Lovelace",
// type code here for "files" field
},
{
"name": "Alan Turing",
"status": "cancelled",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
"timezone": "Ada Lovelace",
"description": "Alan Turing",
"expected_guests": 2,
"budget_total": 9.81,
"budget_spent": 1.59,
"budget_remaining": 0.4,
"internal_notes": "Marie Curie",
// type code here for "files" field
},
{
"name": "Marie Curie",
"status": "planning",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
"timezone": "Grace Hopper",
"description": "Grace Hopper",
"expected_guests": 2,
"budget_total": 0.67,
"budget_spent": 4.94,
"budget_remaining": 8.68,
"internal_notes": "Marie Curie",
// type code here for "files" field
},
{
"name": "Ada Lovelace",
"status": "cancelled",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
"timezone": "Alan Turing",
"description": "Ada Lovelace",
"expected_guests": 3,
"budget_total": 5.16,
"budget_spent": 1.76,
"budget_remaining": 0.09,
"internal_notes": "Ada Lovelace",
// type code here for "files" field
},
{
"name": "Grace Hopper",
"status": "confirmed",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
"timezone": "Grace Hopper",
"description": "Alan Turing",
"expected_guests": 2,
"budget_total": 7.57,
"budget_spent": 8.39,
"budget_remaining": 0.32,
"internal_notes": "Alan Turing",
// type code here for "files" field
},
];
const EventTeamMembersData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"team_role": "guest_services",
"primary_contact": false,
"notes": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"team_role": "lead_planner",
"primary_contact": false,
"notes": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"team_role": "runner",
"primary_contact": true,
"notes": "Ada Lovelace",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"team_role": "guest_services",
"primary_contact": true,
"notes": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"team_role": "other",
"primary_contact": false,
"notes": "Ada Lovelace",
},
];
const EventVendorBookingsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "in_progress",
"estimated_cost": 3.07,
"final_cost": 1.22,
"service_start_at": new Date(Date.now()),
"service_end_at": new Date(Date.now()),
"scope_of_work": "Ada Lovelace",
"contact_person": "Grace Hopper",
"contact_phone": "Grace Hopper",
"contact_email": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "cancelled",
"estimated_cost": 9.04,
"final_cost": 5.61,
"service_start_at": new Date(Date.now()),
"service_end_at": new Date(Date.now()),
"scope_of_work": "Alan Turing",
"contact_person": "Ada Lovelace",
"contact_phone": "Grace Hopper",
"contact_email": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "booked",
"estimated_cost": 2.77,
"final_cost": 8.47,
"service_start_at": new Date(Date.now()),
"service_end_at": new Date(Date.now()),
"scope_of_work": "Marie Curie",
"contact_person": "Marie Curie",
"contact_phone": "Grace Hopper",
"contact_email": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "completed",
"estimated_cost": 7.68,
"final_cost": 7.31,
"service_start_at": new Date(Date.now()),
"service_end_at": new Date(Date.now()),
"scope_of_work": "Marie Curie",
"contact_person": "Alan Turing",
"contact_phone": "Ada Lovelace",
"contact_email": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "in_progress",
"estimated_cost": 4.49,
"final_cost": 5.49,
"service_start_at": new Date(Date.now()),
"service_end_at": new Date(Date.now()),
"scope_of_work": "Ada Lovelace",
"contact_person": "Marie Curie",
"contact_phone": "Alan Turing",
"contact_email": "Ada Lovelace",
// type code here for "files" field
},
];
const ScheduleItemsData = [
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"item_type": "setup",
"status": "cancelled",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Grace Hopper",
"description": "Grace Hopper",
"dependencies": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Alan Turing",
"item_type": "breakdown",
"status": "ready",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Marie Curie",
"description": "Grace Hopper",
"dependencies": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"item_type": "setup",
"status": "blocked",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Marie Curie",
"description": "Grace Hopper",
"dependencies": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Alan Turing",
"item_type": "transport",
"status": "planned",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Marie Curie",
"description": "Grace Hopper",
"dependencies": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"item_type": "ceremony",
"status": "done",
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Marie Curie",
"description": "Ada Lovelace",
"dependencies": "Alan Turing",
// type code here for "files" field
},
];
const TasksData = [
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"status": "done",
"priority": "urgent",
// type code here for "relation_one" field
"due_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"details": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "done",
"priority": "low",
// type code here for "relation_one" field
"due_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"details": "Alan Turing",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "blocked",
"priority": "high",
// type code here for "relation_one" field
"due_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"details": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "todo",
"priority": "medium",
// type code here for "relation_one" field
"due_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"details": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Ada Lovelace",
"status": "in_progress",
"priority": "low",
// type code here for "relation_one" field
"due_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"details": "Alan Turing",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
},
];
const GuestsData = [
{
// type code here for "relation_one" field
"first_name": "Ada Lovelace",
"last_name": "Marie Curie",
"email": "Alan Turing",
"phone": "Marie Curie",
"rsvp_status": "maybe",
"party_size": 4,
"dietary_restrictions": "Grace Hopper",
"accessibility_needs": "Grace Hopper",
"seating_group": "Ada Lovelace",
"notes": "Grace Hopper",
},
{
// type code here for "relation_one" field
"first_name": "Marie Curie",
"last_name": "Alan Turing",
"email": "Alan Turing",
"phone": "Marie Curie",
"rsvp_status": "no",
"party_size": 5,
"dietary_restrictions": "Marie Curie",
"accessibility_needs": "Ada Lovelace",
"seating_group": "Alan Turing",
"notes": "Ada Lovelace",
},
{
// type code here for "relation_one" field
"first_name": "Grace Hopper",
"last_name": "Ada Lovelace",
"email": "Ada Lovelace",
"phone": "Marie Curie",
"rsvp_status": "waitlisted",
"party_size": 9,
"dietary_restrictions": "Alan Turing",
"accessibility_needs": "Marie Curie",
"seating_group": "Marie Curie",
"notes": "Alan Turing",
},
{
// type code here for "relation_one" field
"first_name": "Marie Curie",
"last_name": "Alan Turing",
"email": "Marie Curie",
"phone": "Grace Hopper",
"rsvp_status": "no",
"party_size": 1,
"dietary_restrictions": "Ada Lovelace",
"accessibility_needs": "Grace Hopper",
"seating_group": "Ada Lovelace",
"notes": "Marie Curie",
},
{
// type code here for "relation_one" field
"first_name": "Marie Curie",
"last_name": "Alan Turing",
"email": "Alan Turing",
"phone": "Alan Turing",
"rsvp_status": "waitlisted",
"party_size": 9,
"dietary_restrictions": "Grace Hopper",
"accessibility_needs": "Ada Lovelace",
"seating_group": "Ada Lovelace",
"notes": "Marie Curie",
},
];
const InvitationsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "email",
"sent_at": new Date(Date.now()),
"responded_at": new Date(Date.now()),
"invite_code": "Ada Lovelace",
"message": "Alan Turing",
"delivery_status": "delivered",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "print",
"sent_at": new Date(Date.now()),
"responded_at": new Date(Date.now()),
"invite_code": "Grace Hopper",
"message": "Alan Turing",
"delivery_status": "delivered",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "email",
"sent_at": new Date(Date.now()),
"responded_at": new Date(Date.now()),
"invite_code": "Marie Curie",
"message": "Alan Turing",
"delivery_status": "sent",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "sms",
"sent_at": new Date(Date.now()),
"responded_at": new Date(Date.now()),
"invite_code": "Alan Turing",
"message": "Marie Curie",
"delivery_status": "bounced",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "print",
"sent_at": new Date(Date.now()),
"responded_at": new Date(Date.now()),
"invite_code": "Ada Lovelace",
"message": "Ada Lovelace",
"delivery_status": "bounced",
},
];
const BudgetItemsData = [
{
// type code here for "relation_one" field
"type": "adjustment",
"category": "staffing",
"title": "Grace Hopper",
"amount": 3.28,
"date": new Date(Date.now()),
// type code here for "relation_one" field
"payment_status": "partially_paid",
"notes": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"type": "payment",
"category": "misc",
"title": "Grace Hopper",
"amount": 6.44,
"date": new Date(Date.now()),
// type code here for "relation_one" field
"payment_status": "void",
"notes": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"type": "payment",
"category": "entertainment",
"title": "Ada Lovelace",
"amount": 9.94,
"date": new Date(Date.now()),
// type code here for "relation_one" field
"payment_status": "void",
"notes": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"type": "payment",
"category": "audio_visual",
"title": "Grace Hopper",
"amount": 1.4,
"date": new Date(Date.now()),
// type code here for "relation_one" field
"payment_status": "void",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"type": "adjustment",
"category": "entertainment",
"title": "Grace Hopper",
"amount": 0.79,
"date": new Date(Date.now()),
// type code here for "relation_one" field
"payment_status": "unpaid",
"notes": "Grace Hopper",
// type code here for "files" field
},
];
const CommunicationsData = [
{
// type code here for "relation_one" field
"audience": "vendors",
"channel": "sms",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"occurred_at": new Date(Date.now()),
"subject": "Grace Hopper",
"body": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"audience": "internal_team",
"channel": "email",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"occurred_at": new Date(Date.now()),
"subject": "Alan Turing",
"body": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"audience": "guests",
"channel": "phone",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"occurred_at": new Date(Date.now()),
"subject": "Grace Hopper",
"body": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"audience": "internal_team",
"channel": "phone",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"occurred_at": new Date(Date.now()),
"subject": "Alan Turing",
"body": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"audience": "guests",
"channel": "app_note",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"occurred_at": new Date(Date.now()),
"subject": "Marie Curie",
"body": "Alan Turing",
// type code here for "files" field
},
];
// Similar logic for "relation_many"
async function associateEventWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Event0 = await Events.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Event0?.setVenue)
{
await
Event0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Event1 = await Events.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Event1?.setVenue)
{
await
Event1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Event2 = await Events.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Event2?.setVenue)
{
await
Event2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Event3 = await Events.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Event3?.setVenue)
{
await
Event3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Event4 = await Events.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Event4?.setVenue)
{
await
Event4.
setVenue(relatedVenue4);
}
}
async function associateEventTeamMemberWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventTeamMember0 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (EventTeamMember0?.setEvent)
{
await
EventTeamMember0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventTeamMember1 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (EventTeamMember1?.setEvent)
{
await
EventTeamMember1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventTeamMember2 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (EventTeamMember2?.setEvent)
{
await
EventTeamMember2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventTeamMember3 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (EventTeamMember3?.setEvent)
{
await
EventTeamMember3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventTeamMember4 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (EventTeamMember4?.setEvent)
{
await
EventTeamMember4.
setEvent(relatedEvent4);
}
}
async function associateEventTeamMemberWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const EventTeamMember0 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (EventTeamMember0?.setUser)
{
await
EventTeamMember0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const EventTeamMember1 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (EventTeamMember1?.setUser)
{
await
EventTeamMember1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const EventTeamMember2 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (EventTeamMember2?.setUser)
{
await
EventTeamMember2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const EventTeamMember3 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (EventTeamMember3?.setUser)
{
await
EventTeamMember3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const EventTeamMember4 = await EventTeamMembers.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (EventTeamMember4?.setUser)
{
await
EventTeamMember4.
setUser(relatedUser4);
}
}
async function associateEventVendorBookingWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventVendorBooking0 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (EventVendorBooking0?.setEvent)
{
await
EventVendorBooking0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventVendorBooking1 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (EventVendorBooking1?.setEvent)
{
await
EventVendorBooking1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventVendorBooking2 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (EventVendorBooking2?.setEvent)
{
await
EventVendorBooking2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventVendorBooking3 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (EventVendorBooking3?.setEvent)
{
await
EventVendorBooking3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const EventVendorBooking4 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (EventVendorBooking4?.setEvent)
{
await
EventVendorBooking4.
setEvent(relatedEvent4);
}
}
async function associateEventVendorBookingWithVendor() {
const relatedVendor0 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const EventVendorBooking0 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (EventVendorBooking0?.setVendor)
{
await
EventVendorBooking0.
setVendor(relatedVendor0);
}
const relatedVendor1 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const EventVendorBooking1 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (EventVendorBooking1?.setVendor)
{
await
EventVendorBooking1.
setVendor(relatedVendor1);
}
const relatedVendor2 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const EventVendorBooking2 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (EventVendorBooking2?.setVendor)
{
await
EventVendorBooking2.
setVendor(relatedVendor2);
}
const relatedVendor3 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const EventVendorBooking3 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (EventVendorBooking3?.setVendor)
{
await
EventVendorBooking3.
setVendor(relatedVendor3);
}
const relatedVendor4 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const EventVendorBooking4 = await EventVendorBookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (EventVendorBooking4?.setVendor)
{
await
EventVendorBooking4.
setVendor(relatedVendor4);
}
}
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);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const ScheduleItem4 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ScheduleItem4?.setEvent)
{
await
ScheduleItem4.
setEvent(relatedEvent4);
}
}
async function associateScheduleItemWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScheduleItem0 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScheduleItem0?.setAssigned_to)
{
await
ScheduleItem0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScheduleItem1 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScheduleItem1?.setAssigned_to)
{
await
ScheduleItem1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScheduleItem2 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScheduleItem2?.setAssigned_to)
{
await
ScheduleItem2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScheduleItem3 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ScheduleItem3?.setAssigned_to)
{
await
ScheduleItem3.
setAssigned_to(relatedAssigned_to3);
}
const relatedAssigned_to4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScheduleItem4 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ScheduleItem4?.setAssigned_to)
{
await
ScheduleItem4.
setAssigned_to(relatedAssigned_to4);
}
}
async function associateScheduleItemWithVendor_booking() {
const relatedVendor_booking0 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const ScheduleItem3 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ScheduleItem3?.setVendor_booking)
{
await
ScheduleItem3.
setVendor_booking(relatedVendor_booking3);
}
const relatedVendor_booking4 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const ScheduleItem4 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ScheduleItem4?.setVendor_booking)
{
await
ScheduleItem4.
setVendor_booking(relatedVendor_booking4);
}
}
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);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setEvent)
{
await
Task4.
setEvent(relatedEvent4);
}
}
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);
}
const relatedAssignee4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setAssignee)
{
await
Task4.
setAssignee(relatedAssignee4);
}
}
async function associateTaskWithVendor_booking() {
const relatedVendor_booking0 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setVendor_booking)
{
await
Task0.
setVendor_booking(relatedVendor_booking0);
}
const relatedVendor_booking1 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setVendor_booking)
{
await
Task1.
setVendor_booking(relatedVendor_booking1);
}
const relatedVendor_booking2 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setVendor_booking)
{
await
Task2.
setVendor_booking(relatedVendor_booking2);
}
const relatedVendor_booking3 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setVendor_booking)
{
await
Task3.
setVendor_booking(relatedVendor_booking3);
}
const relatedVendor_booking4 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setVendor_booking)
{
await
Task4.
setVendor_booking(relatedVendor_booking4);
}
}
async function associateTaskWithSchedule_item() {
const relatedSchedule_item0 = await ScheduleItems.findOne({
offset: Math.floor(Math.random() * (await ScheduleItems.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setSchedule_item)
{
await
Task0.
setSchedule_item(relatedSchedule_item0);
}
const relatedSchedule_item1 = await ScheduleItems.findOne({
offset: Math.floor(Math.random() * (await ScheduleItems.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setSchedule_item)
{
await
Task1.
setSchedule_item(relatedSchedule_item1);
}
const relatedSchedule_item2 = await ScheduleItems.findOne({
offset: Math.floor(Math.random() * (await ScheduleItems.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setSchedule_item)
{
await
Task2.
setSchedule_item(relatedSchedule_item2);
}
const relatedSchedule_item3 = await ScheduleItems.findOne({
offset: Math.floor(Math.random() * (await ScheduleItems.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setSchedule_item)
{
await
Task3.
setSchedule_item(relatedSchedule_item3);
}
const relatedSchedule_item4 = await ScheduleItems.findOne({
offset: Math.floor(Math.random() * (await ScheduleItems.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setSchedule_item)
{
await
Task4.
setSchedule_item(relatedSchedule_item4);
}
}
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);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Guest4 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Guest4?.setEvent)
{
await
Guest4.
setEvent(relatedEvent4);
}
}
async function associateInvitationWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Invitation0 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invitation0?.setEvent)
{
await
Invitation0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Invitation1 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invitation1?.setEvent)
{
await
Invitation1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Invitation2 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invitation2?.setEvent)
{
await
Invitation2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Invitation3 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invitation3?.setEvent)
{
await
Invitation3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Invitation4 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invitation4?.setEvent)
{
await
Invitation4.
setEvent(relatedEvent4);
}
}
async function associateInvitationWithGuest() {
const relatedGuest0 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Invitation0 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invitation0?.setGuest)
{
await
Invitation0.
setGuest(relatedGuest0);
}
const relatedGuest1 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Invitation1 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invitation1?.setGuest)
{
await
Invitation1.
setGuest(relatedGuest1);
}
const relatedGuest2 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Invitation2 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invitation2?.setGuest)
{
await
Invitation2.
setGuest(relatedGuest2);
}
const relatedGuest3 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Invitation3 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invitation3?.setGuest)
{
await
Invitation3.
setGuest(relatedGuest3);
}
const relatedGuest4 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Invitation4 = await Invitations.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invitation4?.setGuest)
{
await
Invitation4.
setGuest(relatedGuest4);
}
}
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);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const BudgetItem4 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (BudgetItem4?.setEvent)
{
await
BudgetItem4.
setEvent(relatedEvent4);
}
}
async function associateBudgetItemWithVendor_booking() {
const relatedVendor_booking0 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.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 EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const BudgetItem3 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (BudgetItem3?.setVendor_booking)
{
await
BudgetItem3.
setVendor_booking(relatedVendor_booking3);
}
const relatedVendor_booking4 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const BudgetItem4 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (BudgetItem4?.setVendor_booking)
{
await
BudgetItem4.
setVendor_booking(relatedVendor_booking4);
}
}
async function associateCommunicationWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Communication0 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Communication0?.setEvent)
{
await
Communication0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Communication1 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Communication1?.setEvent)
{
await
Communication1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Communication2 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Communication2?.setEvent)
{
await
Communication2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Communication3 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Communication3?.setEvent)
{
await
Communication3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Communication4 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Communication4?.setEvent)
{
await
Communication4.
setEvent(relatedEvent4);
}
}
async function associateCommunicationWithOwner() {
const relatedOwner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Communication0 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Communication0?.setOwner)
{
await
Communication0.
setOwner(relatedOwner0);
}
const relatedOwner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Communication1 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Communication1?.setOwner)
{
await
Communication1.
setOwner(relatedOwner1);
}
const relatedOwner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Communication2 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Communication2?.setOwner)
{
await
Communication2.
setOwner(relatedOwner2);
}
const relatedOwner3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Communication3 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Communication3?.setOwner)
{
await
Communication3.
setOwner(relatedOwner3);
}
const relatedOwner4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Communication4 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Communication4?.setOwner)
{
await
Communication4.
setOwner(relatedOwner4);
}
}
async function associateCommunicationWithVendor_booking() {
const relatedVendor_booking0 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Communication0 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Communication0?.setVendor_booking)
{
await
Communication0.
setVendor_booking(relatedVendor_booking0);
}
const relatedVendor_booking1 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Communication1 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Communication1?.setVendor_booking)
{
await
Communication1.
setVendor_booking(relatedVendor_booking1);
}
const relatedVendor_booking2 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Communication2 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Communication2?.setVendor_booking)
{
await
Communication2.
setVendor_booking(relatedVendor_booking2);
}
const relatedVendor_booking3 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Communication3 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Communication3?.setVendor_booking)
{
await
Communication3.
setVendor_booking(relatedVendor_booking3);
}
const relatedVendor_booking4 = await EventVendorBookings.findOne({
offset: Math.floor(Math.random() * (await EventVendorBookings.count())),
});
const Communication4 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Communication4?.setVendor_booking)
{
await
Communication4.
setVendor_booking(relatedVendor_booking4);
}
}
async function associateCommunicationWithGuest() {
const relatedGuest0 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Communication0 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Communication0?.setGuest)
{
await
Communication0.
setGuest(relatedGuest0);
}
const relatedGuest1 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Communication1 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Communication1?.setGuest)
{
await
Communication1.
setGuest(relatedGuest1);
}
const relatedGuest2 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Communication2 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Communication2?.setGuest)
{
await
Communication2.
setGuest(relatedGuest2);
}
const relatedGuest3 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Communication3 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Communication3?.setGuest)
{
await
Communication3.
setGuest(relatedGuest3);
}
const relatedGuest4 = await Guests.findOne({
offset: Math.floor(Math.random() * (await Guests.count())),
});
const Communication4 = await Communications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Communication4?.setGuest)
{
await
Communication4.
setGuest(relatedGuest4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Venues.bulkCreate(VenuesData);
await Vendors.bulkCreate(VendorsData);
await Events.bulkCreate(EventsData);
await EventTeamMembers.bulkCreate(EventTeamMembersData);
await EventVendorBookings.bulkCreate(EventVendorBookingsData);
await ScheduleItems.bulkCreate(ScheduleItemsData);
await Tasks.bulkCreate(TasksData);
await Guests.bulkCreate(GuestsData);
await Invitations.bulkCreate(InvitationsData);
await BudgetItems.bulkCreate(BudgetItemsData);
await Communications.bulkCreate(CommunicationsData);
await Promise.all([
// Similar logic for "relation_many"
await associateEventWithVenue(),
await associateEventTeamMemberWithEvent(),
await associateEventTeamMemberWithUser(),
await associateEventVendorBookingWithEvent(),
await associateEventVendorBookingWithVendor(),
await associateScheduleItemWithEvent(),
await associateScheduleItemWithAssigned_to(),
await associateScheduleItemWithVendor_booking(),
await associateTaskWithEvent(),
await associateTaskWithAssignee(),
await associateTaskWithVendor_booking(),
await associateTaskWithSchedule_item(),
await associateGuestWithEvent(),
await associateInvitationWithEvent(),
await associateInvitationWithGuest(),
await associateBudgetItemWithEvent(),
await associateBudgetItemWithVendor_booking(),
await associateCommunicationWithEvent(),
await associateCommunicationWithOwner(),
await associateCommunicationWithVendor_booking(),
await associateCommunicationWithGuest(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('venues', null, {});
await queryInterface.bulkDelete('vendors', null, {});
await queryInterface.bulkDelete('events', null, {});
await queryInterface.bulkDelete('event_team_members', null, {});
await queryInterface.bulkDelete('event_vendor_bookings', null, {});
await queryInterface.bulkDelete('schedule_items', null, {});
await queryInterface.bulkDelete('tasks', null, {});
await queryInterface.bulkDelete('guests', null, {});
await queryInterface.bulkDelete('invitations', null, {});
await queryInterface.bulkDelete('budget_items', null, {});
await queryInterface.bulkDelete('communications', null, {});
},
};