const db = require('../models'); const Users = db.users; const Budgets = db.budgets; const Events = db.events; const Guests = db.guests; const Vendors = db.vendors; const Venues = db.venues; const Categories = db.categories; const BudgetsData = [ { total_amount: 10000, spent_amount: 7500, // type code here for "relation_one" field }, { total_amount: 5000, spent_amount: 3000, // type code here for "relation_one" field }, { total_amount: 15000, spent_amount: 12000, // type code here for "relation_one" field }, { total_amount: 2000, spent_amount: 1500, // type code here for "relation_one" field }, { total_amount: 8000, spent_amount: 5000, // type code here for "relation_one" field }, ]; const EventsData = [ { title: 'Annual Gala', start_time: new Date('2023-12-15T18:00:00Z'), end_time: new Date('2023-12-15T23:00:00Z'), // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Tech Conference', start_time: new Date('2023-11-20T09:00:00Z'), end_time: new Date('2023-11-20T17:00:00Z'), // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Wedding Reception', start_time: new Date('2023-10-10T16:00:00Z'), end_time: new Date('2023-10-10T22:00:00Z'), // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Corporate Meeting', start_time: new Date('2023-09-05T10:00:00Z'), end_time: new Date('2023-09-05T12:00:00Z'), // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Charity Ball', start_time: new Date('2023-08-25T19:00:00Z'), end_time: new Date('2023-08-25T23:59:00Z'), // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_many" field // type code here for "relation_one" field }, ]; const GuestsData = [ { name: 'John Doe', email: 'john.doe@example.com', rsvp_status: 'NotAttending', vegetarian_option: true, }, { name: 'Jane Smith', email: 'jane.smith@example.com', rsvp_status: 'Attending', vegetarian_option: false, }, { name: 'Alice Johnson', email: 'alice.johnson@example.com', rsvp_status: 'Attending', vegetarian_option: true, }, { name: 'Bob Brown', email: 'bob.brown@example.com', rsvp_status: 'Pending', vegetarian_option: false, }, { name: 'Emily White', email: 'emily.white@example.com', rsvp_status: 'Pending', vegetarian_option: true, }, ]; const VendorsData = [ { name: 'Gourmet Catering', contact_info: 'info@gourmetcatering.com', type: 'Caterer', rating: 4.5, }, { name: 'Elegant Decor', contact_info: 'contact@elegantdecor.com', type: 'Entertainer', rating: 4.7, }, { name: 'DJ Beats', contact_info: 'djbeats@music.com', type: 'Caterer', rating: 4.8, }, { name: 'Floral Fantasy', contact_info: 'flowers@floralfantasy.com', type: 'Entertainer', rating: 4.6, }, { name: 'Party Planners', contact_info: 'hello@partyplanners.com', type: 'Entertainer', rating: 4.4, }, ]; const VenuesData = [ { name: 'Grand Ballroom', location: 'Downtown', capacity: 500, is_booked: false, // type code here for "relation_many" field }, { name: 'Rooftop Terrace', location: 'City Center', capacity: 200, is_booked: true, // type code here for "relation_many" field }, { name: 'Conference Hall A', location: 'Tech Park', capacity: 300, is_booked: false, // type code here for "relation_many" field }, { name: 'Garden Pavilion', location: 'Suburbs', capacity: 150, is_booked: true, // type code here for "relation_many" field }, { name: 'Main Auditorium', location: 'University Campus', capacity: 1000, is_booked: true, // type code here for "relation_many" field }, ]; const CategoriesData = [ { name: 'Jean Baptiste Lamarck', }, { name: 'Frederick Sanger', }, { name: 'Franz Boas', }, { name: 'Paul Ehrlich', }, { name: 'John von Neumann', }, ]; // Similar logic for "relation_many" 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 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); } } // Similar logic for "relation_many" // Similar logic for "relation_many" async function associateEventWithBudget() { const relatedBudget0 = await Budgets.findOne({ offset: Math.floor(Math.random() * (await Budgets.count())), }); const Event0 = await Events.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Event0?.setBudget) { await Event0.setBudget(relatedBudget0); } const relatedBudget1 = await Budgets.findOne({ offset: Math.floor(Math.random() * (await Budgets.count())), }); const Event1 = await Events.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Event1?.setBudget) { await Event1.setBudget(relatedBudget1); } const relatedBudget2 = await Budgets.findOne({ offset: Math.floor(Math.random() * (await Budgets.count())), }); const Event2 = await Events.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Event2?.setBudget) { await Event2.setBudget(relatedBudget2); } const relatedBudget3 = await Budgets.findOne({ offset: Math.floor(Math.random() * (await Budgets.count())), }); const Event3 = await Events.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Event3?.setBudget) { await Event3.setBudget(relatedBudget3); } const relatedBudget4 = await Budgets.findOne({ offset: Math.floor(Math.random() * (await Budgets.count())), }); const Event4 = await Events.findOne({ order: [['id', 'ASC']], offset: 4, }); if (Event4?.setBudget) { await Event4.setBudget(relatedBudget4); } } // Similar logic for "relation_many" module.exports = { up: async (queryInterface, Sequelize) => { await Budgets.bulkCreate(BudgetsData); await Events.bulkCreate(EventsData); await Guests.bulkCreate(GuestsData); await Vendors.bulkCreate(VendorsData); await Venues.bulkCreate(VenuesData); await Categories.bulkCreate(CategoriesData); await Promise.all([ // Similar logic for "relation_many" await associateBudgetWithEvent(), await associateEventWithVenue(), // Similar logic for "relation_many" // Similar logic for "relation_many" await associateEventWithBudget(), // Similar logic for "relation_many" ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('budgets', null, {}); await queryInterface.bulkDelete('events', null, {}); await queryInterface.bulkDelete('guests', null, {}); await queryInterface.bulkDelete('vendors', null, {}); await queryInterface.bulkDelete('venues', null, {}); await queryInterface.bulkDelete('categories', null, {}); }, };