307 lines
5.1 KiB
JavaScript
307 lines
5.1 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Budgets = db.budgets;
|
|
|
|
const Guests = db.guests;
|
|
|
|
const Schedules = db.schedules;
|
|
|
|
const Vendors = db.vendors;
|
|
|
|
const Venues = db.venues;
|
|
|
|
const BudgetsData = [
|
|
{
|
|
name: 'Gala Budget',
|
|
|
|
amount: 15000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Wedding Budget',
|
|
|
|
amount: 20000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Launch Budget',
|
|
|
|
amount: 5000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Meeting Budget',
|
|
|
|
amount: 3000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const GuestsData = [
|
|
{
|
|
name: 'John Doe',
|
|
|
|
email: 'john.doe@example.com',
|
|
|
|
rsvp_status: 'not_attending',
|
|
|
|
vegetarian_option: true,
|
|
},
|
|
|
|
{
|
|
name: 'Jane Smith',
|
|
|
|
email: 'jane.smith@example.com',
|
|
|
|
rsvp_status: 'not_attending',
|
|
|
|
vegetarian_option: false,
|
|
},
|
|
|
|
{
|
|
name: 'Michael Brown',
|
|
|
|
email: 'michael.brown@example.com',
|
|
|
|
rsvp_status: 'not_attending',
|
|
|
|
vegetarian_option: true,
|
|
},
|
|
|
|
{
|
|
name: 'Emily Davis',
|
|
|
|
email: 'emily.davis@example.com',
|
|
|
|
rsvp_status: 'not_attending',
|
|
|
|
vegetarian_option: true,
|
|
},
|
|
];
|
|
|
|
const SchedulesData = [
|
|
{
|
|
title: 'Corporate Gala',
|
|
|
|
start_time: new Date('2023-11-15T18:00:00Z'),
|
|
|
|
end_time: new Date('2023-11-15T23:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
|
|
{
|
|
title: 'Wedding Reception',
|
|
|
|
start_time: new Date('2023-12-20T17:00:00Z'),
|
|
|
|
end_time: new Date('2023-12-20T22:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
|
|
{
|
|
title: 'Product Launch',
|
|
|
|
start_time: new Date('2023-10-05T09:00:00Z'),
|
|
|
|
end_time: new Date('2023-10-05T12:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
|
|
{
|
|
title: 'Annual Meeting',
|
|
|
|
start_time: new Date('2023-09-10T10:00:00Z'),
|
|
|
|
end_time: new Date('2023-09-10T15:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
];
|
|
|
|
const VendorsData = [
|
|
{
|
|
name: 'Gourmet Catering',
|
|
|
|
contact_info: 'contact@gourmetcatering.com',
|
|
|
|
type: 'caterer',
|
|
|
|
rating: 4.5,
|
|
},
|
|
|
|
{
|
|
name: 'Elegant Decor',
|
|
|
|
contact_info: 'info@elegantdecor.com',
|
|
|
|
type: 'caterer',
|
|
|
|
rating: 4.7,
|
|
},
|
|
|
|
{
|
|
name: 'DJ Beats',
|
|
|
|
contact_info: 'djbeats@music.com',
|
|
|
|
type: 'decorator',
|
|
|
|
rating: 4.8,
|
|
},
|
|
|
|
{
|
|
name: 'Floral Arrangements',
|
|
|
|
contact_info: 'flowers@floralarrangements.com',
|
|
|
|
type: 'decorator',
|
|
|
|
rating: 4.6,
|
|
},
|
|
];
|
|
|
|
const VenuesData = [
|
|
{
|
|
name: 'Grand Ballroom',
|
|
|
|
location: 'Downtown',
|
|
|
|
capacity: 500,
|
|
|
|
features: 'Stage, Sound System, Lighting',
|
|
|
|
is_booked: false,
|
|
},
|
|
|
|
{
|
|
name: 'Rooftop Terrace',
|
|
|
|
location: 'City Center',
|
|
|
|
capacity: 150,
|
|
|
|
features: 'Open Air, Scenic View',
|
|
|
|
is_booked: true,
|
|
},
|
|
|
|
{
|
|
name: 'Conference Hall A',
|
|
|
|
location: 'Business District',
|
|
|
|
capacity: 300,
|
|
|
|
features: 'Projector, Wi-Fi',
|
|
|
|
is_booked: false,
|
|
},
|
|
|
|
{
|
|
name: 'Garden Venue',
|
|
|
|
location: 'Suburbs',
|
|
|
|
capacity: 200,
|
|
|
|
features: 'Outdoor, Greenery',
|
|
|
|
is_booked: true,
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateBudgetWithEvent() {
|
|
const relatedEvent0 = await Schedules.findOne({
|
|
offset: Math.floor(Math.random() * (await Schedules.count())),
|
|
});
|
|
const Budget0 = await Budgets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Budget0?.setEvent) {
|
|
await Budget0.setEvent(relatedEvent0);
|
|
}
|
|
|
|
const relatedEvent1 = await Schedules.findOne({
|
|
offset: Math.floor(Math.random() * (await Schedules.count())),
|
|
});
|
|
const Budget1 = await Budgets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Budget1?.setEvent) {
|
|
await Budget1.setEvent(relatedEvent1);
|
|
}
|
|
|
|
const relatedEvent2 = await Schedules.findOne({
|
|
offset: Math.floor(Math.random() * (await Schedules.count())),
|
|
});
|
|
const Budget2 = await Budgets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Budget2?.setEvent) {
|
|
await Budget2.setEvent(relatedEvent2);
|
|
}
|
|
|
|
const relatedEvent3 = await Schedules.findOne({
|
|
offset: Math.floor(Math.random() * (await Schedules.count())),
|
|
});
|
|
const Budget3 = await Budgets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Budget3?.setEvent) {
|
|
await Budget3.setEvent(relatedEvent3);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Budgets.bulkCreate(BudgetsData);
|
|
|
|
await Guests.bulkCreate(GuestsData);
|
|
|
|
await Schedules.bulkCreate(SchedulesData);
|
|
|
|
await Vendors.bulkCreate(VendorsData);
|
|
|
|
await Venues.bulkCreate(VenuesData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateBudgetWithEvent(),
|
|
|
|
// Similar logic for "relation_many"
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('budgets', null, {});
|
|
|
|
await queryInterface.bulkDelete('guests', null, {});
|
|
|
|
await queryInterface.bulkDelete('schedules', null, {});
|
|
|
|
await queryInterface.bulkDelete('vendors', null, {});
|
|
|
|
await queryInterface.bulkDelete('venues', null, {});
|
|
},
|
|
};
|