1005 lines
25 KiB
JavaScript
1005 lines
25 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Admins = db.admins;
|
|
|
|
const CompanyInsights = db.company_insights;
|
|
|
|
const PlacementDrives = db.placement_drives;
|
|
|
|
const Students = db.students;
|
|
|
|
const Tpos = db.tpos;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const AdminsData = [
|
|
{
|
|
full_name: 'Vikram Singh',
|
|
|
|
email: 'vikram.singh@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Neha Gupta',
|
|
|
|
email: 'neha.gupta@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Rajesh Kumar',
|
|
|
|
email: 'rajesh.kumar@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Pooja Agarwal',
|
|
|
|
email: 'pooja.agarwal@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Amit Desai',
|
|
|
|
email: 'amit.desai@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const CompanyInsightsData = [
|
|
{
|
|
company_name: 'TechCorp',
|
|
|
|
students_placed: 50,
|
|
|
|
average_package: 8.5,
|
|
|
|
department_breakdown: 'CS: 20, IT: 15, ECE: 15',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Innovate Solutions',
|
|
|
|
students_placed: 30,
|
|
|
|
average_package: 7.2,
|
|
|
|
department_breakdown: 'CS: 10, IT: 10, ECE: 10',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'FutureTech',
|
|
|
|
students_placed: 40,
|
|
|
|
average_package: 9,
|
|
|
|
department_breakdown: 'CS: 15, IT: 15, ECE: 10',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Pioneer Systems',
|
|
|
|
students_placed: 25,
|
|
|
|
average_package: 6.8,
|
|
|
|
department_breakdown: 'CS: 10, IT: 5, ECE: 10',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Visionary Inc.',
|
|
|
|
students_placed: 35,
|
|
|
|
average_package: 7.5,
|
|
|
|
department_breakdown: 'CS: 15, IT: 10, ECE: 10',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PlacementDrivesData = [
|
|
{
|
|
title: 'Tech Drive 2023',
|
|
|
|
start_date: new Date('2023-11-01T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-05T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Innovate 2023',
|
|
|
|
start_date: new Date('2023-12-01T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-12-03T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Career Fest 2023',
|
|
|
|
start_date: new Date('2023-10-15T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-17T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Job Fair 2023',
|
|
|
|
start_date: new Date('2023-09-20T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-09-22T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Opportunity Expo 2023',
|
|
|
|
start_date: new Date('2023-08-10T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-08-12T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const StudentsData = [
|
|
{
|
|
full_name: 'Aarushi Patel',
|
|
|
|
email: 'aarushi.patel@example.com',
|
|
|
|
phone_number: '9876543210',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Meera Shah',
|
|
|
|
email: 'meera.shah@example.com',
|
|
|
|
phone_number: '9876543211',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Nisha Mehta',
|
|
|
|
email: 'nisha.mehta@example.com',
|
|
|
|
phone_number: '9876543212',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Riya Desai',
|
|
|
|
email: 'riya.desai@example.com',
|
|
|
|
phone_number: '9876543213',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Sneha Joshi',
|
|
|
|
email: 'sneha.joshi@example.com',
|
|
|
|
phone_number: '9876543214',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const TposData = [
|
|
{
|
|
full_name: 'Kavita Rao',
|
|
|
|
email: 'kavita.rao@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Anjali Verma',
|
|
|
|
email: 'anjali.verma@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Priya Nair',
|
|
|
|
email: 'priya.nair@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Sonal Kapoor',
|
|
|
|
email: 'sonal.kapoor@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
full_name: 'Radhika Iyer',
|
|
|
|
email: 'radhika.iyer@example.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Tech University',
|
|
},
|
|
|
|
{
|
|
name: 'Innovate Institute',
|
|
},
|
|
|
|
{
|
|
name: 'Future College',
|
|
},
|
|
|
|
{
|
|
name: 'Pioneer Academy',
|
|
},
|
|
|
|
{
|
|
name: 'Vision University',
|
|
},
|
|
];
|
|
|
|
// 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 associateAdminWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin0 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Admin0?.setOrganization) {
|
|
await Admin0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin1 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Admin1?.setOrganization) {
|
|
await Admin1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin2 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Admin2?.setOrganization) {
|
|
await Admin2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin3 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Admin3?.setOrganization) {
|
|
await Admin3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin4 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Admin4?.setOrganization) {
|
|
await Admin4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateAdminWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin0 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Admin0?.setOrganization) {
|
|
await Admin0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin1 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Admin1?.setOrganization) {
|
|
await Admin1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin2 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Admin2?.setOrganization) {
|
|
await Admin2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin3 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Admin3?.setOrganization) {
|
|
await Admin3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Admin4 = await Admins.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Admin4?.setOrganization) {
|
|
await Admin4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateCompanyInsightWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const CompanyInsight0 = await CompanyInsights.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (CompanyInsight0?.setOrganization) {
|
|
await CompanyInsight0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const CompanyInsight1 = await CompanyInsights.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (CompanyInsight1?.setOrganization) {
|
|
await CompanyInsight1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const CompanyInsight2 = await CompanyInsights.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (CompanyInsight2?.setOrganization) {
|
|
await CompanyInsight2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const CompanyInsight3 = await CompanyInsights.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (CompanyInsight3?.setOrganization) {
|
|
await CompanyInsight3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const CompanyInsight4 = await CompanyInsights.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (CompanyInsight4?.setOrganization) {
|
|
await CompanyInsight4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePlacementDrifeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife0 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlacementDrife0?.setOrganization) {
|
|
await PlacementDrife0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife1 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlacementDrife1?.setOrganization) {
|
|
await PlacementDrife1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife2 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlacementDrife2?.setOrganization) {
|
|
await PlacementDrife2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife3 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlacementDrife3?.setOrganization) {
|
|
await PlacementDrife3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife4 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlacementDrife4?.setOrganization) {
|
|
await PlacementDrife4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associatePlacementDrifeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife0 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlacementDrife0?.setOrganization) {
|
|
await PlacementDrife0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife1 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlacementDrife1?.setOrganization) {
|
|
await PlacementDrife1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife2 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlacementDrife2?.setOrganization) {
|
|
await PlacementDrife2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife3 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlacementDrife3?.setOrganization) {
|
|
await PlacementDrife3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PlacementDrife4 = await PlacementDrives.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlacementDrife4?.setOrganization) {
|
|
await PlacementDrife4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateStudentWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student0 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Student0?.setOrganization) {
|
|
await Student0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student1 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Student1?.setOrganization) {
|
|
await Student1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student2 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Student2?.setOrganization) {
|
|
await Student2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student3 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Student3?.setOrganization) {
|
|
await Student3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student4 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Student4?.setOrganization) {
|
|
await Student4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateStudentWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student0 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Student0?.setOrganization) {
|
|
await Student0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student1 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Student1?.setOrganization) {
|
|
await Student1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student2 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Student2?.setOrganization) {
|
|
await Student2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student3 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Student3?.setOrganization) {
|
|
await Student3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Student4 = await Students.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Student4?.setOrganization) {
|
|
await Student4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateTpoWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo0 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Tpo0?.setOrganization) {
|
|
await Tpo0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo1 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Tpo1?.setOrganization) {
|
|
await Tpo1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo2 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Tpo2?.setOrganization) {
|
|
await Tpo2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo3 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Tpo3?.setOrganization) {
|
|
await Tpo3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo4 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Tpo4?.setOrganization) {
|
|
await Tpo4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateTpoWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo0 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Tpo0?.setOrganization) {
|
|
await Tpo0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo1 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Tpo1?.setOrganization) {
|
|
await Tpo1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo2 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Tpo2?.setOrganization) {
|
|
await Tpo2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo3 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Tpo3?.setOrganization) {
|
|
await Tpo3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Tpo4 = await Tpos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Tpo4?.setOrganization) {
|
|
await Tpo4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Admins.bulkCreate(AdminsData);
|
|
|
|
await CompanyInsights.bulkCreate(CompanyInsightsData);
|
|
|
|
await PlacementDrives.bulkCreate(PlacementDrivesData);
|
|
|
|
await Students.bulkCreate(StudentsData);
|
|
|
|
await Tpos.bulkCreate(TposData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateAdminWithOrganization(),
|
|
|
|
await associateAdminWithOrganization(),
|
|
|
|
await associateCompanyInsightWithOrganization(),
|
|
|
|
await associatePlacementDrifeWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associatePlacementDrifeWithOrganization(),
|
|
|
|
await associateStudentWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateStudentWithOrganization(),
|
|
|
|
await associateTpoWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateTpoWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('admins', null, {});
|
|
|
|
await queryInterface.bulkDelete('company_insights', null, {});
|
|
|
|
await queryInterface.bulkDelete('placement_drives', null, {});
|
|
|
|
await queryInterface.bulkDelete('students', null, {});
|
|
|
|
await queryInterface.bulkDelete('tpos', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|