39559-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-04-11 16:13:51 +00:00

7010 lines
136 KiB
JavaScript

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 Contracts = db.contracts;
const Tasks = db.tasks;
const ScheduleItems = db.schedule_items;
const GuestGroups = db.guest_groups;
const Guests = db.guests;
const Invitations = db.invitations;
const BudgetItems = db.budget_items;
const Payments = db.payments;
const Comments = db.comments;
const EventsData = [
{
"name": "Grace Hopper",
"event_type": "conference",
"status": "planning",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"description": "Grace Hopper",
"internal_notes": "Alan Turing",
"expected_guest_count": 6,
"budget_total": 4.76,
"budget_actual_total": 0.2,
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Alan Turing",
"event_type": "wedding",
"status": "in_progress",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"description": "Grace Hopper",
"internal_notes": "Grace Hopper",
"expected_guest_count": 4,
"budget_total": 1.19,
"budget_actual_total": 0.38,
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Ada Lovelace",
"event_type": "other",
"status": "draft",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"description": "Marie Curie",
"internal_notes": "Grace Hopper",
"expected_guest_count": 1,
"budget_total": 2.07,
"budget_actual_total": 5.87,
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "images" field
// type code here for "files" field
},
{
"name": "Alan Turing",
"event_type": "conference",
"status": "planning",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"description": "Alan Turing",
"internal_notes": "Alan Turing",
"expected_guest_count": 6,
"budget_total": 5.57,
"budget_actual_total": 3.74,
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "images" field
// type code here for "files" field
},
];
const VenuesData = [
{
"name": "Grace Hopper",
"venue_type": "theater",
"status": "confirmed",
"address_line_1": "Grace Hopper",
"address_line_2": "Ada Lovelace",
"city": "Grace Hopper",
"state_region": "Marie Curie",
"postal_code": "Marie Curie",
"country": "Grace Hopper",
"contact_name": "Ada Lovelace",
"contact_email": "Marie Curie",
"contact_phone": "Ada Lovelace",
"capacity": 9,
"rental_fee_estimate": 1.1,
"notes": "Marie Curie",
// type code here for "files" field
},
{
"name": "Marie Curie",
"venue_type": "other",
"status": "hold_requested",
"address_line_1": "Alan Turing",
"address_line_2": "Grace Hopper",
"city": "Alan Turing",
"state_region": "Ada Lovelace",
"postal_code": "Alan Turing",
"country": "Alan Turing",
"contact_name": "Alan Turing",
"contact_email": "Grace Hopper",
"contact_phone": "Marie Curie",
"capacity": 5,
"rental_fee_estimate": 4.53,
"notes": "Grace Hopper",
// type code here for "files" field
},
{
"name": "Grace Hopper",
"venue_type": "outdoor",
"status": "held",
"address_line_1": "Alan Turing",
"address_line_2": "Ada Lovelace",
"city": "Grace Hopper",
"state_region": "Grace Hopper",
"postal_code": "Ada Lovelace",
"country": "Grace Hopper",
"contact_name": "Marie Curie",
"contact_email": "Ada Lovelace",
"contact_phone": "Grace Hopper",
"capacity": 6,
"rental_fee_estimate": 9.42,
"notes": "Grace Hopper",
// type code here for "files" field
},
{
"name": "Ada Lovelace",
"venue_type": "outdoor",
"status": "cancelled",
"address_line_1": "Alan Turing",
"address_line_2": "Alan Turing",
"city": "Marie Curie",
"state_region": "Grace Hopper",
"postal_code": "Grace Hopper",
"country": "Grace Hopper",
"contact_name": "Grace Hopper",
"contact_email": "Alan Turing",
"contact_phone": "Grace Hopper",
"capacity": 9,
"rental_fee_estimate": 6.58,
"notes": "Alan Turing",
// type code here for "files" field
},
];
const VendorsData = [
{
"name": "Ada Lovelace",
"category": "catering",
"status": "prospecting",
"contact_name": "Grace Hopper",
"contact_email": "Ada Lovelace",
"contact_phone": "Marie Curie",
"website": "Marie Curie",
"address": "Ada Lovelace",
"default_rate_estimate": 8.52,
"notes": "Marie Curie",
// type code here for "files" field
},
{
"name": "Marie Curie",
"category": "security",
"status": "cancelled",
"contact_name": "Alan Turing",
"contact_email": "Marie Curie",
"contact_phone": "Grace Hopper",
"website": "Marie Curie",
"address": "Alan Turing",
"default_rate_estimate": 7.53,
"notes": "Alan Turing",
// type code here for "files" field
},
{
"name": "Grace Hopper",
"category": "security",
"status": "booked",
"contact_name": "Ada Lovelace",
"contact_email": "Marie Curie",
"contact_phone": "Marie Curie",
"website": "Marie Curie",
"address": "Grace Hopper",
"default_rate_estimate": 1.09,
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
"name": "Marie Curie",
"category": "staffing",
"status": "shortlisted",
"contact_name": "Ada Lovelace",
"contact_email": "Ada Lovelace",
"contact_phone": "Ada Lovelace",
"website": "Alan Turing",
"address": "Alan Turing",
"default_rate_estimate": 3.5,
"notes": "Marie Curie",
// type code here for "files" field
},
];
const EventVendorsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"engagement_status": "done",
// type code here for "relation_one" field
"service_start_datetime": new Date(Date.now()),
"service_end_datetime": new Date(Date.now()),
"estimated_cost": 6.07,
"actual_cost": 9.56,
"scope_of_work": "Marie Curie",
"notes": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"engagement_status": "cancelled",
// type code here for "relation_one" field
"service_start_datetime": new Date(Date.now()),
"service_end_datetime": new Date(Date.now()),
"estimated_cost": 6.93,
"actual_cost": 8.93,
"scope_of_work": "Ada Lovelace",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"engagement_status": "booked",
// type code here for "relation_one" field
"service_start_datetime": new Date(Date.now()),
"service_end_datetime": new Date(Date.now()),
"estimated_cost": 4.15,
"actual_cost": 4.89,
"scope_of_work": "Marie Curie",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"engagement_status": "requested",
// type code here for "relation_one" field
"service_start_datetime": new Date(Date.now()),
"service_end_datetime": new Date(Date.now()),
"estimated_cost": 9.88,
"actual_cost": 8.02,
"scope_of_work": "Alan Turing",
"notes": "Grace Hopper",
// type code here for "files" field
},
];
const ContractsData = [
{
"title": "Alan Turing",
// type code here for "relation_one" field
"party_type": "vendor",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "sent",
"sent_datetime": new Date(Date.now()),
"signed_datetime": new Date(Date.now()),
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"contract_value": 3.47,
"deposit_amount": 7.64,
"deposit_due_datetime": new Date(Date.now()),
"terms_summary": "Ada Lovelace",
// type code here for "files" field
},
{
"title": "Alan Turing",
// type code here for "relation_one" field
"party_type": "venue",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "expired",
"sent_datetime": new Date(Date.now()),
"signed_datetime": new Date(Date.now()),
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"contract_value": 7.65,
"deposit_amount": 7.83,
"deposit_due_datetime": new Date(Date.now()),
"terms_summary": "Ada Lovelace",
// type code here for "files" field
},
{
"title": "Ada Lovelace",
// type code here for "relation_one" field
"party_type": "other",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "active",
"sent_datetime": new Date(Date.now()),
"signed_datetime": new Date(Date.now()),
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"contract_value": 3.51,
"deposit_amount": 1.72,
"deposit_due_datetime": new Date(Date.now()),
"terms_summary": "Grace Hopper",
// type code here for "files" field
},
{
"title": "Marie Curie",
// type code here for "relation_one" field
"party_type": "venue",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "sent",
"sent_datetime": new Date(Date.now()),
"signed_datetime": new Date(Date.now()),
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
"contract_value": 0.37,
"deposit_amount": 3.02,
"deposit_due_datetime": new Date(Date.now()),
"terms_summary": "Grace Hopper",
// type code here for "files" field
},
];
const TasksData = [
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "cancelled",
"priority": "medium",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"due_datetime": new Date(Date.now()),
"completed_datetime": new Date(Date.now()),
"sort_order": 2,
"details": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Ada Lovelace",
"status": "done",
"priority": "urgent",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"due_datetime": new Date(Date.now()),
"completed_datetime": new Date(Date.now()),
"sort_order": 8,
"details": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "in_progress",
"priority": "high",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"due_datetime": new Date(Date.now()),
"completed_datetime": new Date(Date.now()),
"sort_order": 5,
"details": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"status": "done",
"priority": "medium",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"due_datetime": new Date(Date.now()),
"completed_datetime": new Date(Date.now()),
"sort_order": 3,
"details": "Ada Lovelace",
// type code here for "files" field
},
];
const ScheduleItemsData = [
{
// type code here for "relation_one" field
"title": "Ada Lovelace",
"item_type": "other",
"status": "completed",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Ada Lovelace",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Ada Lovelace",
"item_type": "tear_down",
"status": "cancelled",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Alan Turing",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Alan Turing",
"item_type": "ceremony",
"status": "in_progress",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Ada Lovelace",
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"item_type": "other",
"status": "in_progress",
"start_datetime": new Date(Date.now()),
"end_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"location_detail": "Ada Lovelace",
"notes": "Ada Lovelace",
// type code here for "files" field
},
];
const GuestGroupsData = [
{
// type code here for "relation_one" field
"name": "Marie Curie",
"group_type": "family",
"notes": "Grace Hopper",
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"group_type": "vendors",
"notes": "Grace Hopper",
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"group_type": "vendors",
"notes": "Ada Lovelace",
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"group_type": "coworkers",
"notes": "Ada Lovelace",
},
];
const GuestsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Marie Curie",
"email": "Grace Hopper",
"phone": "Marie Curie",
"rsvp_status": "declined",
"party_size": 5,
"vip": true,
"checked_in": true,
"rsvp_datetime": new Date(Date.now()),
"dietary_requirements": "Marie Curie",
"notes": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Ada Lovelace",
"email": "Grace Hopper",
"phone": "Marie Curie",
"rsvp_status": "invited",
"party_size": 8,
"vip": false,
"checked_in": false,
"rsvp_datetime": new Date(Date.now()),
"dietary_requirements": "Marie Curie",
"notes": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Grace Hopper",
"email": "Grace Hopper",
"phone": "Grace Hopper",
"rsvp_status": "waitlisted",
"party_size": 7,
"vip": true,
"checked_in": true,
"rsvp_datetime": new Date(Date.now()),
"dietary_requirements": "Grace Hopper",
"notes": "Ada Lovelace",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Ada Lovelace",
"email": "Grace Hopper",
"phone": "Grace Hopper",
"rsvp_status": "no_response",
"party_size": 2,
"vip": true,
"checked_in": false,
"rsvp_datetime": new Date(Date.now()),
"dietary_requirements": "Grace Hopper",
"notes": "Grace Hopper",
},
];
const InvitationsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "email",
"status": "scheduled",
"scheduled_datetime": new Date(Date.now()),
"sent_datetime": new Date(Date.now()),
"message": "Grace Hopper",
"tracking_code": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "sms",
"status": "failed",
"scheduled_datetime": new Date(Date.now()),
"sent_datetime": new Date(Date.now()),
"message": "Ada Lovelace",
"tracking_code": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "print",
"status": "failed",
"scheduled_datetime": new Date(Date.now()),
"sent_datetime": new Date(Date.now()),
"message": "Marie Curie",
"tracking_code": "Grace Hopper",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"channel": "sms",
"status": "scheduled",
"scheduled_datetime": new Date(Date.now()),
"sent_datetime": new Date(Date.now()),
"message": "Grace Hopper",
"tracking_code": "Grace Hopper",
},
];
const BudgetItemsData = [
{
// type code here for "relation_one" field
"name": "Marie Curie",
"category": "entertainment",
"status": "committed",
"estimated_amount": 5.82,
"actual_amount": 2.39,
"due_datetime": new Date(Date.now()),
"paid_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"notes": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"category": "catering",
"status": "planned",
"estimated_amount": 9.48,
"actual_amount": 8.71,
"due_datetime": new Date(Date.now()),
"paid_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"notes": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"category": "decor",
"status": "committed",
"estimated_amount": 4.97,
"actual_amount": 9.19,
"due_datetime": new Date(Date.now()),
"paid_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"notes": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"category": "entertainment",
"status": "paid",
"estimated_amount": 1.17,
"actual_amount": 0.94,
"due_datetime": new Date(Date.now()),
"paid_datetime": new Date(Date.now()),
// type code here for "relation_one" field
// type code here for "relation_one" field
"notes": "Alan Turing",
// type code here for "files" field
},
];
const PaymentsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"method": "cash",
"status": "cancelled",
"amount": 6.43,
"payment_datetime": new Date(Date.now()),
"reference": "Grace Hopper",
"notes": "Alan Turing",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"method": "other",
"status": "refunded",
"amount": 2.69,
"payment_datetime": new Date(Date.now()),
"reference": "Alan Turing",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"method": "other",
"status": "scheduled",
"amount": 7.51,
"payment_datetime": new Date(Date.now()),
"reference": "Ada Lovelace",
"notes": "Grace Hopper",
// type code here for "files" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"method": "card",
"status": "cancelled",
"amount": 2.79,
"payment_datetime": new Date(Date.now()),
"reference": "Marie Curie",
"notes": "Alan Turing",
// type code here for "files" field
},
];
const CommentsData = [
{
// type code here for "relation_one" field
"target_type": "guest",
"target_ref": "Alan Turing",
// type code here for "relation_one" field
"commented_datetime": new Date(Date.now()),
"body": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"target_type": "budget_item",
"target_ref": "Ada Lovelace",
// type code here for "relation_one" field
"commented_datetime": new Date(Date.now()),
"body": "Ada Lovelace",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"target_type": "schedule_item",
"target_ref": "Ada Lovelace",
// type code here for "relation_one" field
"commented_datetime": new Date(Date.now()),
"body": "Marie Curie",
// type code here for "files" field
},
{
// type code here for "relation_one" field
"target_type": "event",
"target_ref": "Marie Curie",
// type code here for "relation_one" field
"commented_datetime": new Date(Date.now()),
"body": "Ada Lovelace",
// type code here for "files" field
},
];
// Similar logic for "relation_many"
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 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 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 associateContractWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Contract0 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Contract0?.setEvent)
{
await
Contract0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Contract1 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Contract1?.setEvent)
{
await
Contract1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Contract2 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Contract2?.setEvent)
{
await
Contract2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Contract3 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Contract3?.setEvent)
{
await
Contract3.
setEvent(relatedEvent3);
}
}
async function associateContractWithVendor() {
const relatedVendor0 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const Contract0 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Contract0?.setVendor)
{
await
Contract0.
setVendor(relatedVendor0);
}
const relatedVendor1 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const Contract1 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Contract1?.setVendor)
{
await
Contract1.
setVendor(relatedVendor1);
}
const relatedVendor2 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const Contract2 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Contract2?.setVendor)
{
await
Contract2.
setVendor(relatedVendor2);
}
const relatedVendor3 = await Vendors.findOne({
offset: Math.floor(Math.random() * (await Vendors.count())),
});
const Contract3 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Contract3?.setVendor)
{
await
Contract3.
setVendor(relatedVendor3);
}
}
async function associateContractWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Contract0 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Contract0?.setVenue)
{
await
Contract0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Contract1 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Contract1?.setVenue)
{
await
Contract1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Contract2 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Contract2?.setVenue)
{
await
Contract2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Contract3 = await Contracts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Contract3?.setVenue)
{
await
Contract3.
setVenue(relatedVenue3);
}
}
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 associateTaskWithVendor_engagement() {
const relatedVendor_engagement0 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setVendor_engagement)
{
await
Task0.
setVendor_engagement(relatedVendor_engagement0);
}
const relatedVendor_engagement1 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setVendor_engagement)
{
await
Task1.
setVendor_engagement(relatedVendor_engagement1);
}
const relatedVendor_engagement2 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setVendor_engagement)
{
await
Task2.
setVendor_engagement(relatedVendor_engagement2);
}
const relatedVendor_engagement3 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setVendor_engagement)
{
await
Task3.
setVendor_engagement(relatedVendor_engagement3);
}
}
async function associateTaskWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setVenue)
{
await
Task0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setVenue)
{
await
Task1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setVenue)
{
await
Task2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setVenue)
{
await
Task3.
setVenue(relatedVenue3);
}
}
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_engagement() {
const relatedVendor_engagement0 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const ScheduleItem0 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScheduleItem0?.setVendor_engagement)
{
await
ScheduleItem0.
setVendor_engagement(relatedVendor_engagement0);
}
const relatedVendor_engagement1 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const ScheduleItem1 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScheduleItem1?.setVendor_engagement)
{
await
ScheduleItem1.
setVendor_engagement(relatedVendor_engagement1);
}
const relatedVendor_engagement2 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const ScheduleItem2 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScheduleItem2?.setVendor_engagement)
{
await
ScheduleItem2.
setVendor_engagement(relatedVendor_engagement2);
}
const relatedVendor_engagement3 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const ScheduleItem3 = await ScheduleItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ScheduleItem3?.setVendor_engagement)
{
await
ScheduleItem3.
setVendor_engagement(relatedVendor_engagement3);
}
}
async function associateGuestGroupWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const GuestGroup0 = await GuestGroups.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (GuestGroup0?.setEvent)
{
await
GuestGroup0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const GuestGroup1 = await GuestGroups.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (GuestGroup1?.setEvent)
{
await
GuestGroup1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const GuestGroup2 = await GuestGroups.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (GuestGroup2?.setEvent)
{
await
GuestGroup2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const GuestGroup3 = await GuestGroups.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (GuestGroup3?.setEvent)
{
await
GuestGroup3.
setEvent(relatedEvent3);
}
}
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 associateGuestWithGroup() {
const relatedGroup0 = await GuestGroups.findOne({
offset: Math.floor(Math.random() * (await GuestGroups.count())),
});
const Guest0 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Guest0?.setGroup)
{
await
Guest0.
setGroup(relatedGroup0);
}
const relatedGroup1 = await GuestGroups.findOne({
offset: Math.floor(Math.random() * (await GuestGroups.count())),
});
const Guest1 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Guest1?.setGroup)
{
await
Guest1.
setGroup(relatedGroup1);
}
const relatedGroup2 = await GuestGroups.findOne({
offset: Math.floor(Math.random() * (await GuestGroups.count())),
});
const Guest2 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Guest2?.setGroup)
{
await
Guest2.
setGroup(relatedGroup2);
}
const relatedGroup3 = await GuestGroups.findOne({
offset: Math.floor(Math.random() * (await GuestGroups.count())),
});
const Guest3 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Guest3?.setGroup)
{
await
Guest3.
setGroup(relatedGroup3);
}
}
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);
}
}
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);
}
}
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_engagement() {
const relatedVendor_engagement0 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const BudgetItem0 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (BudgetItem0?.setVendor_engagement)
{
await
BudgetItem0.
setVendor_engagement(relatedVendor_engagement0);
}
const relatedVendor_engagement1 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const BudgetItem1 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (BudgetItem1?.setVendor_engagement)
{
await
BudgetItem1.
setVendor_engagement(relatedVendor_engagement1);
}
const relatedVendor_engagement2 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const BudgetItem2 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (BudgetItem2?.setVendor_engagement)
{
await
BudgetItem2.
setVendor_engagement(relatedVendor_engagement2);
}
const relatedVendor_engagement3 = await EventVendors.findOne({
offset: Math.floor(Math.random() * (await EventVendors.count())),
});
const BudgetItem3 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (BudgetItem3?.setVendor_engagement)
{
await
BudgetItem3.
setVendor_engagement(relatedVendor_engagement3);
}
}
async function associateBudgetItemWithOwner() {
const relatedOwner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BudgetItem0 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (BudgetItem0?.setOwner)
{
await
BudgetItem0.
setOwner(relatedOwner0);
}
const relatedOwner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BudgetItem1 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (BudgetItem1?.setOwner)
{
await
BudgetItem1.
setOwner(relatedOwner1);
}
const relatedOwner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BudgetItem2 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (BudgetItem2?.setOwner)
{
await
BudgetItem2.
setOwner(relatedOwner2);
}
const relatedOwner3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BudgetItem3 = await BudgetItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (BudgetItem3?.setOwner)
{
await
BudgetItem3.
setOwner(relatedOwner3);
}
}
async function associatePaymentWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setEvent)
{
await
Payment0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setEvent)
{
await
Payment1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setEvent)
{
await
Payment2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setEvent)
{
await
Payment3.
setEvent(relatedEvent3);
}
}
async function associatePaymentWithBudget_item() {
const relatedBudget_item0 = await BudgetItems.findOne({
offset: Math.floor(Math.random() * (await BudgetItems.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setBudget_item)
{
await
Payment0.
setBudget_item(relatedBudget_item0);
}
const relatedBudget_item1 = await BudgetItems.findOne({
offset: Math.floor(Math.random() * (await BudgetItems.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setBudget_item)
{
await
Payment1.
setBudget_item(relatedBudget_item1);
}
const relatedBudget_item2 = await BudgetItems.findOne({
offset: Math.floor(Math.random() * (await BudgetItems.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setBudget_item)
{
await
Payment2.
setBudget_item(relatedBudget_item2);
}
const relatedBudget_item3 = await BudgetItems.findOne({
offset: Math.floor(Math.random() * (await BudgetItems.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setBudget_item)
{
await
Payment3.
setBudget_item(relatedBudget_item3);
}
}
async function associateCommentWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setEvent)
{
await
Comment0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setEvent)
{
await
Comment1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setEvent)
{
await
Comment2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Comment3 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Comment3?.setEvent)
{
await
Comment3.
setEvent(relatedEvent3);
}
}
async function associateCommentWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setAuthor)
{
await
Comment0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setAuthor)
{
await
Comment1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setAuthor)
{
await
Comment2.
setAuthor(relatedAuthor2);
}
const relatedAuthor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment3 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Comment3?.setAuthor)
{
await
Comment3.
setAuthor(relatedAuthor3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Events.bulkCreate(EventsData);
await Venues.bulkCreate(VenuesData);
await Vendors.bulkCreate(VendorsData);
await EventVendors.bulkCreate(EventVendorsData);
await Contracts.bulkCreate(ContractsData);
await Tasks.bulkCreate(TasksData);
await ScheduleItems.bulkCreate(ScheduleItemsData);
await GuestGroups.bulkCreate(GuestGroupsData);
await Guests.bulkCreate(GuestsData);
await Invitations.bulkCreate(InvitationsData);
await BudgetItems.bulkCreate(BudgetItemsData);
await Payments.bulkCreate(PaymentsData);
await Comments.bulkCreate(CommentsData);
await Promise.all([
// Similar logic for "relation_many"
await associateEventWithOwner(),
await associateEventWithPrimary_venue(),
await associateEventVendorWithEvent(),
await associateEventVendorWithVendor(),
await associateEventVendorWithOwner(),
await associateContractWithEvent(),
await associateContractWithVendor(),
await associateContractWithVenue(),
await associateTaskWithEvent(),
await associateTaskWithAssignee(),
await associateTaskWithVendor_engagement(),
await associateTaskWithVenue(),
await associateScheduleItemWithEvent(),
await associateScheduleItemWithOwner(),
await associateScheduleItemWithVenue(),
await associateScheduleItemWithVendor_engagement(),
await associateGuestGroupWithEvent(),
await associateGuestWithEvent(),
await associateGuestWithGroup(),
await associateInvitationWithEvent(),
await associateInvitationWithGuest(),
await associateBudgetItemWithEvent(),
await associateBudgetItemWithVendor_engagement(),
await associateBudgetItemWithOwner(),
await associatePaymentWithEvent(),
await associatePaymentWithBudget_item(),
await associateCommentWithEvent(),
await associateCommentWithAuthor(),
]);
},
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('contracts', null, {});
await queryInterface.bulkDelete('tasks', null, {});
await queryInterface.bulkDelete('schedule_items', null, {});
await queryInterface.bulkDelete('guest_groups', null, {});
await queryInterface.bulkDelete('guests', null, {});
await queryInterface.bulkDelete('invitations', null, {});
await queryInterface.bulkDelete('budget_items', null, {});
await queryInterface.bulkDelete('payments', null, {});
await queryInterface.bulkDelete('comments', null, {});
},
};