37834-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-01-26 12:28:37 +00:00

3880 lines
82 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Organizations = db.organizations;
const Venues = db.venues;
const Vendors = db.vendors;
const Guests = db.guests;
const Schedules = db.schedules;
const Budgets = db.budgets;
const Tasks = db.tasks;
const Events = db.events;
const OrganizationsData = [
{
"name": "Grace Hopper",
},
{
"name": "Marie Curie",
},
{
"name": "Alan Turing",
},
{
"name": "Grace Hopper",
},
{
"name": "Ada Lovelace",
},
];
const VenuesData = [
{
"name": "Harborview Convention Hall",
"address": "125 Harbor Way, Cityville, CA 94105",
"capacity": 800,
"contact_name": "Daniel Kim",
"contact_phone": "+1-415-555-0111",
// type code here for "files" field
"indoor": true,
// type code here for "relation_one" field
},
{
"name": "Grand Oak Ballroom",
"address": "220 Oak Street, Townsville, NY 10012",
"capacity": 320,
"contact_name": "Elena Brooks",
"contact_phone": "+1-212-555-0133",
// type code here for "files" field
"indoor": true,
// type code here for "relation_one" field
},
{
"name": "Summit Conference Center",
"address": "10 Summit Drive, Hilltown, CO 80401",
"capacity": 1200,
"contact_name": "Carlos Mendez",
"contact_phone": "+1-303-555-0166",
// type code here for "files" field
"indoor": true,
// type code here for "relation_one" field
},
{
"name": "Riverside Pavilion",
"address": "77 Riverside Ave, Riverton, OH 44101",
"capacity": 250,
"contact_name": "Nina Patel",
"contact_phone": "+1-216-555-0144",
// type code here for "files" field
"indoor": true,
// type code here for "relation_one" field
},
{
"name": "Maple Community Center",
"address": "5 Maple Lane, Brookfield, IL 60007",
"capacity": 150,
"contact_name": "James OConnor",
"contact_phone": "+1-847-555-0155",
// type code here for "files" field
"indoor": true,
// type code here for "relation_one" field
},
];
const VendorsData = [
{
"name": "FineTaste Catering",
"category": "Photography",
"contact_name": "Rachel Green",
"contact_email": "rachel@finetaste.com",
"contact_phone": "+1-415-555-0211",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "BrightLight AV",
"category": "Other",
"contact_name": "Omar Ali",
"contact_email": "omar@brightlight.com",
"contact_phone": "+1-303-555-0222",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "PetalWorks Decor",
"category": "Photography",
"contact_name": "Hannah Lee",
"contact_email": "hannah@petalworks.com",
"contact_phone": "+1-212-555-0233",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "FrameCapture Studio",
"category": "Decor",
"contact_name": "Diego Fernandez",
"contact_email": "diego@framecapture.com",
"contact_phone": "+1-847-555-0244",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "Express Transit",
"category": "Decor",
"contact_name": "Priya Kumar",
"contact_email": "priya@expresstransit.com",
"contact_phone": "+1-216-555-0255",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
];
const GuestsData = [
{
"full_name": "Ethan Williams",
"email": "ethan.williams@example.com",
"phone": "+1-202-555-0311",
"rsvp_status": "Attending",
// type code here for "relation_one" field
"plus_ones": 1,
// type code here for "relation_one" field
},
{
"full_name": "Grace Liu",
"email": "grace.liu@example.com",
"phone": "+1-202-555-0322",
"rsvp_status": "NotAttending",
// type code here for "relation_one" field
"plus_ones": 0,
// type code here for "relation_one" field
},
{
"full_name": "Noah Brooks",
"email": "noah.brooks@example.com",
"phone": "+1-202-555-0333",
"rsvp_status": "Attending",
// type code here for "relation_one" field
"plus_ones": 2,
// type code here for "relation_one" field
},
{
"full_name": "Isabella Garcia",
"email": "isabella.garcia@example.com",
"phone": "+1-202-555-0344",
"rsvp_status": "Pending",
// type code here for "relation_one" field
"plus_ones": 0,
// type code here for "relation_one" field
},
{
"full_name": "Michael Johnson",
"email": "michael.johnson@example.com",
"phone": "+1-202-555-0355",
"rsvp_status": "Pending",
// type code here for "relation_one" field
"plus_ones": 0,
// type code here for "relation_one" field
},
];
const SchedulesData = [
{
"title": "Vendor Load In",
"start": new Date('2026-04-10T07:00:00Z'),
"end": new Date('2026-04-10T09:00:00Z'),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location": "Harborview Loading Dock",
"status": "Scheduled",
// type code here for "relation_one" field
},
{
"title": "Opening Remarks",
"start": new Date('2026-06-20T18:00:00Z'),
"end": new Date('2026-06-20T18:30:00Z'),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location": "Grand Oak Main Hall",
"status": "Cancelled",
// type code here for "relation_one" field
},
{
"title": "Keynote Session",
"start": new Date('2026-09-15T09:30:00Z'),
"end": new Date('2026-09-15T11:00:00Z'),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location": "Summit Conference Room A",
"status": "Scheduled",
// type code here for "relation_one" field
},
{
"title": "Exhibitor Setup",
"start": new Date('2026-07-02T08:00:00Z'),
"end": new Date('2026-07-02T12:00:00Z'),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location": "Riverside Pavilion Grounds",
"status": "Cancelled",
// type code here for "relation_one" field
},
{
"title": "Volunteer Briefing",
"start": new Date('2026-11-05T08:30:00Z'),
"end": new Date('2026-11-05T09:15:00Z'),
// type code here for "relation_one" field
// type code here for "relation_one" field
"location": "Maple Community Center Lobby",
"status": "Completed",
// type code here for "relation_one" field
},
];
const BudgetsData = [
{
"title": "Launch Event Budget",
"total_amount": 25000.0,
"spent_amount": 7200.5,
// type code here for "relation_one" field
"currency": "GBP",
"notes": "Initial deposits to caterer and AV vendor",
// type code here for "relation_one" field
},
{
"title": "Gala Budget",
"total_amount": 50000.0,
"spent_amount": 18250.0,
// type code here for "relation_one" field
"currency": "USD",
"notes": "Venue and decor estimates included",
// type code here for "relation_one" field
},
{
"title": "Conference Budget",
"total_amount": 120000.0,
"spent_amount": 45000.0,
// type code here for "relation_one" field
"currency": "Other",
"notes": "Sponsorships tracked separately",
// type code here for "relation_one" field
},
{
"title": "Expo Budget",
"total_amount": 30000.0,
"spent_amount": 9800.0,
// type code here for "relation_one" field
"currency": "Other",
"notes": "Booth allocations and marketing",
// type code here for "relation_one" field
},
{
"title": "Fundraiser Budget",
"total_amount": 8000.0,
"spent_amount": 1200.0,
// type code here for "relation_one" field
"currency": "GBP",
"notes": "Local vendor discounts applied",
// type code here for "relation_one" field
},
];
const TasksData = [
{
"title": "Confirm Caterer Menu",
"description": "Finalize menu choices and dietary restrictions with FineTaste Catering",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "ToDo",
"due_date": new Date('2026-03-25T17:00:00Z'),
"priority": 2,
// type code here for "relation_one" field
},
{
"title": "Finalize AV Run of Show",
"description": "Coordinate with BrightLight AV for run of show and mic checks",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "Done",
"due_date": new Date('2026-04-08T12:00:00Z'),
"priority": 1,
// type code here for "relation_one" field
},
{
"title": "Print Programs",
"description": "Design and approve printed programs for conference sessions",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "Done",
"due_date": new Date('2026-09-01T09:00:00Z'),
"priority": 3,
// type code here for "relation_one" field
},
{
"title": "Vendor Parking Plan",
"description": "Create parking and access plan for exhibitors and vendors",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "Blocked",
"due_date": new Date('2026-07-01T12:00:00Z'),
"priority": 2,
// type code here for "relation_one" field
},
{
"title": "Volunteer Roster",
"description": "Compile volunteer assignments and contact list",
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "InProgress",
"due_date": new Date('2026-10-25T10:00:00Z'),
"priority": 2,
// type code here for "relation_one" field
},
];
const EventsData = [
{
"title": "Spring Product Launch",
"description": "Company product launch with invited press and partners",
// type code here for "relation_one" field
// type code here for "relation_one" field
"start": new Date('2026-04-10T09:00:00Z'),
"end": new Date('2026-04-10T17:00:00Z'),
"status": "Completed",
"estimated_budget": 25000.0,
// type code here for "relation_one" field
},
{
"title": "Summer Gala",
"description": "Annual fundraising gala with seated dinner and program",
// type code here for "relation_one" field
// type code here for "relation_one" field
"start": new Date('2026-06-20T18:00:00Z'),
"end": new Date('2026-06-20T23:00:00Z'),
"status": "Cancelled",
"estimated_budget": 50000.0,
// type code here for "relation_one" field
},
{
"title": "Tech Conference 2026",
"description": "Two day conference focused on developer tools and best practices",
// type code here for "relation_one" field
// type code here for "relation_one" field
"start": new Date('2026-09-15T08:00:00Z'),
"end": new Date('2026-09-16T17:00:00Z'),
"status": "Draft",
"estimated_budget": 120000.0,
// type code here for "relation_one" field
},
{
"title": "Wedding Expo",
"description": "Open expo for couples to meet vendors and view showcases",
// type code here for "relation_one" field
// type code here for "relation_one" field
"start": new Date('2026-07-02T10:00:00Z'),
"end": new Date('2026-07-02T16:00:00Z'),
"status": "Planned",
"estimated_budget": 30000.0,
// type code here for "relation_one" field
},
{
"title": "Community Fundraiser",
"description": "Local community fundraising event with auctions and booths",
// type code here for "relation_one" field
// type code here for "relation_one" field
"start": new Date('2026-11-05T09:00:00Z'),
"end": new Date('2026-11-05T13:00:00Z'),
"status": "Active",
"estimated_budget": 8000.0,
// type code here for "relation_one" field
},
];
// Similar logic for "relation_many"
async function associateUserWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User0 = await Users.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (User0?.setOrganization)
{
await
User0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User1 = await Users.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (User1?.setOrganization)
{
await
User1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User2 = await Users.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (User2?.setOrganization)
{
await
User2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (User3?.setOrganization)
{
await
User3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User4 = await Users.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (User4?.setOrganization)
{
await
User4.
setOrganization(relatedOrganization4);
}
}
async function associateVenueWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue0 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Venue0?.setOrganization)
{
await
Venue0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue1 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Venue1?.setOrganization)
{
await
Venue1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue2 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Venue2?.setOrganization)
{
await
Venue2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue3 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Venue3?.setOrganization)
{
await
Venue3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue4 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Venue4?.setOrganization)
{
await
Venue4.
setOrganization(relatedOrganization4);
}
}
// Similar logic for "relation_many"
async function associateVendorWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Vendor0 = await Vendors.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Vendor0?.setOrganization)
{
await
Vendor0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Vendor1 = await Vendors.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Vendor1?.setOrganization)
{
await
Vendor1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Vendor2 = await Vendors.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Vendor2?.setOrganization)
{
await
Vendor2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Vendor3 = await Vendors.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Vendor3?.setOrganization)
{
await
Vendor3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Vendor4 = await Vendors.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Vendor4?.setOrganization)
{
await
Vendor4.
setOrganization(relatedOrganization4);
}
}
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 associateGuestWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Guest0 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Guest0?.setOrganization)
{
await
Guest0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Guest1 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Guest1?.setOrganization)
{
await
Guest1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Guest2 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Guest2?.setOrganization)
{
await
Guest2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Guest3 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Guest3?.setOrganization)
{
await
Guest3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Guest4 = await Guests.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Guest4?.setOrganization)
{
await
Guest4.
setOrganization(relatedOrganization4);
}
}
async function associateScheduleWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Schedule0 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Schedule0?.setEvent)
{
await
Schedule0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Schedule1 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Schedule1?.setEvent)
{
await
Schedule1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Schedule2 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Schedule2?.setEvent)
{
await
Schedule2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Schedule3 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Schedule3?.setEvent)
{
await
Schedule3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Schedule4 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Schedule4?.setEvent)
{
await
Schedule4.
setEvent(relatedEvent4);
}
}
async function associateScheduleWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Schedule0 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Schedule0?.setAssigned_to)
{
await
Schedule0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Schedule1 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Schedule1?.setAssigned_to)
{
await
Schedule1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Schedule2 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Schedule2?.setAssigned_to)
{
await
Schedule2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Schedule3 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Schedule3?.setAssigned_to)
{
await
Schedule3.
setAssigned_to(relatedAssigned_to3);
}
const relatedAssigned_to4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Schedule4 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Schedule4?.setAssigned_to)
{
await
Schedule4.
setAssigned_to(relatedAssigned_to4);
}
}
async function associateScheduleWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Schedule0 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Schedule0?.setOrganization)
{
await
Schedule0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Schedule1 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Schedule1?.setOrganization)
{
await
Schedule1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Schedule2 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Schedule2?.setOrganization)
{
await
Schedule2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Schedule3 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Schedule3?.setOrganization)
{
await
Schedule3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Schedule4 = await Schedules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Schedule4?.setOrganization)
{
await
Schedule4.
setOrganization(relatedOrganization4);
}
}
async function associateBudgetWithEvent() {
const relatedEvent0 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Budget0 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Budget0?.setEvent)
{
await
Budget0.
setEvent(relatedEvent0);
}
const relatedEvent1 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Budget1 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Budget1?.setEvent)
{
await
Budget1.
setEvent(relatedEvent1);
}
const relatedEvent2 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Budget2 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Budget2?.setEvent)
{
await
Budget2.
setEvent(relatedEvent2);
}
const relatedEvent3 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Budget3 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Budget3?.setEvent)
{
await
Budget3.
setEvent(relatedEvent3);
}
const relatedEvent4 = await Events.findOne({
offset: Math.floor(Math.random() * (await Events.count())),
});
const Budget4 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Budget4?.setEvent)
{
await
Budget4.
setEvent(relatedEvent4);
}
}
async function associateBudgetWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Budget0 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Budget0?.setOrganization)
{
await
Budget0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Budget1 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Budget1?.setOrganization)
{
await
Budget1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Budget2 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Budget2?.setOrganization)
{
await
Budget2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Budget3 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Budget3?.setOrganization)
{
await
Budget3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Budget4 = await Budgets.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Budget4?.setOrganization)
{
await
Budget4.
setOrganization(relatedOrganization4);
}
}
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 associateTaskWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setAssigned_to)
{
await
Task0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setAssigned_to)
{
await
Task1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setAssigned_to)
{
await
Task2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setAssigned_to)
{
await
Task3.
setAssigned_to(relatedAssigned_to3);
}
const relatedAssigned_to4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setAssigned_to)
{
await
Task4.
setAssigned_to(relatedAssigned_to4);
}
}
async function associateTaskWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Task0 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Task0?.setOrganization)
{
await
Task0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Task1 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Task1?.setOrganization)
{
await
Task1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Task2 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Task2?.setOrganization)
{
await
Task2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Task3 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Task3?.setOrganization)
{
await
Task3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Task4 = await Tasks.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Task4?.setOrganization)
{
await
Task4.
setOrganization(relatedOrganization4);
}
}
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 associateEventWithOrganizer() {
const relatedOrganizer0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Event0 = await Events.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Event0?.setOrganizer)
{
await
Event0.
setOrganizer(relatedOrganizer0);
}
const relatedOrganizer1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Event1 = await Events.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Event1?.setOrganizer)
{
await
Event1.
setOrganizer(relatedOrganizer1);
}
const relatedOrganizer2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Event2 = await Events.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Event2?.setOrganizer)
{
await
Event2.
setOrganizer(relatedOrganizer2);
}
const relatedOrganizer3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Event3 = await Events.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Event3?.setOrganizer)
{
await
Event3.
setOrganizer(relatedOrganizer3);
}
const relatedOrganizer4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Event4 = await Events.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Event4?.setOrganizer)
{
await
Event4.
setOrganizer(relatedOrganizer4);
}
}
async function associateEventWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Event0 = await Events.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Event0?.setOrganization)
{
await
Event0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Event1 = await Events.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Event1?.setOrganization)
{
await
Event1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Event2 = await Events.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Event2?.setOrganization)
{
await
Event2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Event3 = await Events.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Event3?.setOrganization)
{
await
Event3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Event4 = await Events.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Event4?.setOrganization)
{
await
Event4.
setOrganization(relatedOrganization4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Organizations.bulkCreate(OrganizationsData);
await Venues.bulkCreate(VenuesData);
await Vendors.bulkCreate(VendorsData);
await Guests.bulkCreate(GuestsData);
await Schedules.bulkCreate(SchedulesData);
await Budgets.bulkCreate(BudgetsData);
await Tasks.bulkCreate(TasksData);
await Events.bulkCreate(EventsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithOrganization(),
await associateVenueWithOrganization(),
// Similar logic for "relation_many"
await associateVendorWithOrganization(),
await associateGuestWithEvent(),
await associateGuestWithOrganization(),
await associateScheduleWithEvent(),
await associateScheduleWithAssigned_to(),
await associateScheduleWithOrganization(),
await associateBudgetWithEvent(),
await associateBudgetWithOrganization(),
await associateTaskWithEvent(),
await associateTaskWithAssigned_to(),
await associateTaskWithOrganization(),
await associateEventWithVenue(),
await associateEventWithOrganizer(),
await associateEventWithOrganization(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('organizations', null, {});
await queryInterface.bulkDelete('venues', null, {});
await queryInterface.bulkDelete('vendors', null, {});
await queryInterface.bulkDelete('guests', null, {});
await queryInterface.bulkDelete('schedules', null, {});
await queryInterface.bulkDelete('budgets', null, {});
await queryInterface.bulkDelete('tasks', null, {});
await queryInterface.bulkDelete('events', null, {});
},
};