895 lines
20 KiB
JavaScript
895 lines
20 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Budgets = db.budgets;
|
|
|
|
const Events = db.events;
|
|
|
|
const Guests = db.guests;
|
|
|
|
const Schedules = db.schedules;
|
|
|
|
const Vendors = db.vendors;
|
|
|
|
const Venues = db.venues;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const BudgetsData = [
|
|
{
|
|
name: 'Catering Budget',
|
|
|
|
amount: 15000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Decor Budget',
|
|
|
|
amount: 8000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Entertainment Budget',
|
|
|
|
amount: 5000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Venue Budget',
|
|
|
|
amount: 12000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const EventsData = [
|
|
{
|
|
name: 'Annual Gala',
|
|
|
|
date: new Date('2023-11-10T00:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Tech Conference',
|
|
|
|
date: new Date('2023-12-05T00:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Wedding Reception',
|
|
|
|
date: new Date('2023-10-20T00:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Corporate Retreat',
|
|
|
|
date: new Date('2023-09-15T00:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" 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: true,
|
|
|
|
dietary_preference: 'vegetarian',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Jane Smith',
|
|
|
|
email: 'jane.smith@example.com',
|
|
|
|
rsvp: true,
|
|
|
|
dietary_preference: 'vegetarian',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Michael Brown',
|
|
|
|
email: 'michael.brown@example.com',
|
|
|
|
rsvp: false,
|
|
|
|
dietary_preference: 'gluten_free',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Emily Davis',
|
|
|
|
email: 'emily.davis@example.com',
|
|
|
|
rsvp: true,
|
|
|
|
dietary_preference: 'none',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SchedulesData = [
|
|
{
|
|
title: 'Vendor Setup',
|
|
|
|
start_time: new Date('2023-11-10T08:00:00Z'),
|
|
|
|
end_time: new Date('2023-11-10T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Guest Arrival',
|
|
|
|
start_time: new Date('2023-11-10T18:00:00Z'),
|
|
|
|
end_time: new Date('2023-11-10T19:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Dinner Service',
|
|
|
|
start_time: new Date('2023-11-10T19:30:00Z'),
|
|
|
|
end_time: new Date('2023-11-10T21:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Keynote Speech',
|
|
|
|
start_time: new Date('2023-11-10T21:15:00Z'),
|
|
|
|
end_time: new Date('2023-11-10T22:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const VendorsData = [
|
|
{
|
|
name: 'Gourmet Catering Co.',
|
|
|
|
contact_info: 'info@gourmetcatering.com',
|
|
|
|
type: 'caterer',
|
|
|
|
rating: 4.8,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Elegant Decorators',
|
|
|
|
contact_info: 'contact@elegantdecor.com',
|
|
|
|
type: 'caterer',
|
|
|
|
rating: 4.5,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'DJ Beats',
|
|
|
|
contact_info: 'djbeats@musicmail.com',
|
|
|
|
type: 'decorator',
|
|
|
|
rating: 4.7,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Floral Fantasies',
|
|
|
|
contact_info: 'flowers@floralfantasies.com',
|
|
|
|
type: 'decorator',
|
|
|
|
rating: 4.6,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const VenuesData = [
|
|
{
|
|
name: 'Grand Ballroom',
|
|
|
|
location: 'Downtown',
|
|
|
|
capacity: 500,
|
|
|
|
features: 'Stage, AV Equipment, Catering Available',
|
|
|
|
is_booked: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Rooftop Terrace',
|
|
|
|
location: 'City Center',
|
|
|
|
capacity: 150,
|
|
|
|
features: 'Open Air, Scenic View, Bar',
|
|
|
|
is_booked: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Conference Hall A',
|
|
|
|
location: 'Tech Park',
|
|
|
|
capacity: 300,
|
|
|
|
features: 'Projector, Wi-Fi, Sound System',
|
|
|
|
is_booked: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Garden Pavilion',
|
|
|
|
location: 'Suburban Area',
|
|
|
|
capacity: 200,
|
|
|
|
features: 'Outdoor, Greenery, Tent Available',
|
|
|
|
is_booked: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Karl Landsteiner',
|
|
},
|
|
|
|
{
|
|
name: 'Ernst Haeckel',
|
|
},
|
|
|
|
{
|
|
name: 'Hans Selye',
|
|
},
|
|
|
|
{
|
|
name: 'Edward O. Wilson',
|
|
},
|
|
];
|
|
|
|
// 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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Budgets.bulkCreate(BudgetsData);
|
|
|
|
await Events.bulkCreate(EventsData);
|
|
|
|
await Guests.bulkCreate(GuestsData);
|
|
|
|
await Schedules.bulkCreate(SchedulesData);
|
|
|
|
await Vendors.bulkCreate(VendorsData);
|
|
|
|
await Venues.bulkCreate(VenuesData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateBudgetWithEvent(),
|
|
|
|
await associateBudgetWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateEventWithOrganization(),
|
|
|
|
await associateGuestWithEvent(),
|
|
|
|
await associateGuestWithOrganization(),
|
|
|
|
await associateScheduleWithEvent(),
|
|
|
|
await associateScheduleWithOrganization(),
|
|
|
|
await associateVendorWithOrganization(),
|
|
|
|
await associateVenueWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('budgets', null, {});
|
|
|
|
await queryInterface.bulkDelete('events', null, {});
|
|
|
|
await queryInterface.bulkDelete('guests', null, {});
|
|
|
|
await queryInterface.bulkDelete('schedules', null, {});
|
|
|
|
await queryInterface.bulkDelete('vendors', null, {});
|
|
|
|
await queryInterface.bulkDelete('venues', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|