2067 lines
53 KiB
JavaScript
2067 lines
53 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Assets = db.assets;
|
|
|
|
const AttendanceRecords = db.attendance_records;
|
|
|
|
const Communications = db.communications;
|
|
|
|
const Compensations = db.compensations;
|
|
|
|
const ComplianceDocuments = db.compliance_documents;
|
|
|
|
const Employees = db.employees;
|
|
|
|
const ExitInformation = db.exit_information;
|
|
|
|
const HealthRecords = db.health_records;
|
|
|
|
const JobDetails = db.job_details;
|
|
|
|
const PerformanceReviews = db.performance_reviews;
|
|
|
|
const ProfessionalDevelopment = db.professional_development;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const AssetsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
equipment_name: 'James Watson',
|
|
|
|
software_licenses: 'Edward Teller',
|
|
|
|
access_cards: 'Neils Bohr',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
equipment_name: 'Archimedes',
|
|
|
|
software_licenses: 'Paul Ehrlich',
|
|
|
|
access_cards: 'John Dalton',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
equipment_name: 'Stephen Hawking',
|
|
|
|
software_licenses: 'Lynn Margulis',
|
|
|
|
access_cards: 'August Kekule',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
equipment_name: 'Alexander Fleming',
|
|
|
|
software_licenses: 'Emil Kraepelin',
|
|
|
|
access_cards: 'Alfred Wegener',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const AttendanceRecordsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
work_date: new Date(Date.now()),
|
|
|
|
work_hours: 4,
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
work_date: new Date(Date.now()),
|
|
|
|
work_hours: 5,
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
work_date: new Date(Date.now()),
|
|
|
|
work_hours: 6,
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
work_date: new Date(Date.now()),
|
|
|
|
work_hours: 6,
|
|
|
|
present: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const CommunicationsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
internal_communications: 'Sheldon Glashow',
|
|
|
|
team_memberships: 'Francis Crick',
|
|
|
|
project_involvement: 'Christiaan Huygens',
|
|
|
|
meetings_attended: 'Louis Pasteur',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
internal_communications: 'Marie Curie',
|
|
|
|
team_memberships: 'Marcello Malpighi',
|
|
|
|
project_involvement: 'Max von Laue',
|
|
|
|
meetings_attended: 'Johannes Kepler',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
internal_communications: 'Jean Baptiste Lamarck',
|
|
|
|
team_memberships: 'Dmitri Mendeleev',
|
|
|
|
project_involvement: 'Murray Gell-Mann',
|
|
|
|
meetings_attended: 'Paul Ehrlich',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
internal_communications: 'Claude Levi-Strauss',
|
|
|
|
team_memberships: 'Enrico Fermi',
|
|
|
|
project_involvement: 'Ludwig Boltzmann',
|
|
|
|
meetings_attended: 'Frederick Sanger',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const CompensationsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 34.56,
|
|
|
|
bonuses: 12.44,
|
|
|
|
benefits: 'Alfred Kinsey',
|
|
|
|
retirement_plan: 'Carl Gauss (Karl Friedrich Gauss)',
|
|
|
|
insurance_details: 'Wilhelm Wundt',
|
|
|
|
tax_information: 'James Watson',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 61.38,
|
|
|
|
bonuses: 86.22,
|
|
|
|
benefits: 'Antoine Laurent Lavoisier',
|
|
|
|
retirement_plan: 'John von Neumann',
|
|
|
|
insurance_details: 'Charles Sherrington',
|
|
|
|
tax_information: 'Alexander Fleming',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 69.69,
|
|
|
|
bonuses: 26.52,
|
|
|
|
benefits: 'Frederick Sanger',
|
|
|
|
retirement_plan: 'Francis Crick',
|
|
|
|
insurance_details: 'Louis Victor de Broglie',
|
|
|
|
tax_information: 'Claude Bernard',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 39.06,
|
|
|
|
bonuses: 56.91,
|
|
|
|
benefits: 'Max von Laue',
|
|
|
|
retirement_plan: 'Johannes Kepler',
|
|
|
|
insurance_details: 'Werner Heisenberg',
|
|
|
|
tax_information: 'Max Planck',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ComplianceDocumentsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
visa_status: 'Paul Dirac',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
visa_status: 'Stephen Hawking',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
visa_status: 'James Clerk Maxwell',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
// type code here for "files" field
|
|
|
|
visa_status: 'John Dalton',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const EmployeesData = [
|
|
{
|
|
name: 'Albrecht von Haller',
|
|
|
|
employee_id: 'Johannes Kepler',
|
|
|
|
contact_details: 'Albert Einstein',
|
|
|
|
address: 'Lynn Margulis',
|
|
|
|
emergency_contact: 'Werner Heisenberg',
|
|
|
|
// 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
|
|
|
|
// 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_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Gertrude Belle Elion',
|
|
|
|
employee_id: 'Ernst Mayr',
|
|
|
|
contact_details: 'Rudolf Virchow',
|
|
|
|
address: 'Carl Linnaeus',
|
|
|
|
emergency_contact: 'August Kekule',
|
|
|
|
// 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
|
|
|
|
// 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_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'John von Neumann',
|
|
|
|
employee_id: 'Comte de Buffon',
|
|
|
|
contact_details: 'Erwin Schrodinger',
|
|
|
|
address: 'Max Delbruck',
|
|
|
|
emergency_contact: 'Ernst Mayr',
|
|
|
|
// 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
|
|
|
|
// 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_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Enrico Fermi',
|
|
|
|
employee_id: 'Heike Kamerlingh Onnes',
|
|
|
|
contact_details: 'Murray Gell-Mann',
|
|
|
|
address: 'Ernst Haeckel',
|
|
|
|
emergency_contact: 'Euclid',
|
|
|
|
// 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
|
|
|
|
// 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_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ExitInformationData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
resignation_date: new Date(Date.now()),
|
|
|
|
exit_interview: 'Albrecht von Haller',
|
|
|
|
reason_for_leaving: 'Enrico Fermi',
|
|
|
|
rehiring_eligibility: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
resignation_date: new Date(Date.now()),
|
|
|
|
exit_interview: 'Claude Levi-Strauss',
|
|
|
|
reason_for_leaving: 'Gregor Mendel',
|
|
|
|
rehiring_eligibility: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
resignation_date: new Date(Date.now()),
|
|
|
|
exit_interview: 'Thomas Hunt Morgan',
|
|
|
|
reason_for_leaving: 'J. Robert Oppenheimer',
|
|
|
|
rehiring_eligibility: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
resignation_date: new Date(Date.now()),
|
|
|
|
exit_interview: 'August Kekule',
|
|
|
|
reason_for_leaving: 'Theodosius Dobzhansky',
|
|
|
|
rehiring_eligibility: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const HealthRecordsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
medical_records: 'Leonard Euler',
|
|
|
|
workplace_incidents: 'Sigmund Freud',
|
|
|
|
accommodations: 'Edward O. Wilson',
|
|
|
|
wellness_programs: 'Alfred Wegener',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
medical_records: 'Heike Kamerlingh Onnes',
|
|
|
|
workplace_incidents: 'Nicolaus Copernicus',
|
|
|
|
accommodations: 'Ernst Mayr',
|
|
|
|
wellness_programs: 'August Kekule',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
medical_records: 'Carl Linnaeus',
|
|
|
|
workplace_incidents: 'Emil Fischer',
|
|
|
|
accommodations: 'Trofim Lysenko',
|
|
|
|
wellness_programs: 'Stephen Hawking',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
medical_records: 'Jean Piaget',
|
|
|
|
workplace_incidents: 'Ernest Rutherford',
|
|
|
|
accommodations: 'Lucretius',
|
|
|
|
wellness_programs: 'Joseph J. Thomson',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const JobDetailsData = [
|
|
{
|
|
position: 'Jonas Salk',
|
|
|
|
department: 'William Herschel',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
job_description: 'Tycho Brahe',
|
|
|
|
date_of_hire: new Date(Date.now()),
|
|
|
|
employment_type: 'contract',
|
|
|
|
work_location: 'Louis Pasteur',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
position: 'Franz Boas',
|
|
|
|
department: 'Carl Gauss (Karl Friedrich Gauss)',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
job_description: 'James Clerk Maxwell',
|
|
|
|
date_of_hire: new Date(Date.now()),
|
|
|
|
employment_type: 'full-time',
|
|
|
|
work_location: 'John Bardeen',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
position: 'Nicolaus Copernicus',
|
|
|
|
department: 'Gustav Kirchhoff',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
job_description: 'William Herschel',
|
|
|
|
date_of_hire: new Date(Date.now()),
|
|
|
|
employment_type: 'contract',
|
|
|
|
work_location: 'Alfred Binet',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
position: 'Paul Dirac',
|
|
|
|
department: 'Arthur Eddington',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
job_description: 'Isaac Newton',
|
|
|
|
date_of_hire: new Date(Date.now()),
|
|
|
|
employment_type: 'full-time',
|
|
|
|
work_location: 'Gustav Kirchhoff',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PerformanceReviewsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
goals: 'Carl Linnaeus',
|
|
|
|
feedback: 'Max Born',
|
|
|
|
review_date: new Date(Date.now()),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
goals: 'Stephen Hawking',
|
|
|
|
feedback: 'J. Robert Oppenheimer',
|
|
|
|
review_date: new Date(Date.now()),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
goals: 'Erwin Schrodinger',
|
|
|
|
feedback: 'Joseph J. Thomson',
|
|
|
|
review_date: new Date(Date.now()),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
goals: 'Dmitri Mendeleev',
|
|
|
|
feedback: 'Louis Pasteur',
|
|
|
|
review_date: new Date(Date.now()),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProfessionalDevelopmentData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
training_attended: 'Frederick Gowland Hopkins',
|
|
|
|
certifications: 'William Bayliss',
|
|
|
|
skills: 'Francis Galton',
|
|
|
|
mentoring: 'Ernst Haeckel',
|
|
|
|
career_path: 'Wilhelm Wundt',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
training_attended: 'Marie Curie',
|
|
|
|
certifications: 'Theodosius Dobzhansky',
|
|
|
|
skills: 'Emil Fischer',
|
|
|
|
mentoring: 'William Harvey',
|
|
|
|
career_path: 'Alfred Kinsey',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
training_attended: 'Noam Chomsky',
|
|
|
|
certifications: 'George Gaylord Simpson',
|
|
|
|
skills: 'Alfred Binet',
|
|
|
|
mentoring: 'Comte de Buffon',
|
|
|
|
career_path: 'Max von Laue',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
training_attended: 'Charles Darwin',
|
|
|
|
certifications: 'George Gaylord Simpson',
|
|
|
|
skills: 'Alfred Wegener',
|
|
|
|
mentoring: 'John Dalton',
|
|
|
|
career_path: 'Paul Dirac',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Christiaan Huygens',
|
|
},
|
|
|
|
{
|
|
name: 'Neils Bohr',
|
|
},
|
|
|
|
{
|
|
name: 'Carl Gauss (Karl Friedrich Gauss)',
|
|
},
|
|
|
|
{
|
|
name: 'John von Neumann',
|
|
},
|
|
];
|
|
|
|
// 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 associateAssetWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset0 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Asset0?.setEmployee) {
|
|
await Asset0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset1 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Asset1?.setEmployee) {
|
|
await Asset1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset2 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Asset2?.setEmployee) {
|
|
await Asset2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset3 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Asset3?.setEmployee) {
|
|
await Asset3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateAssetWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset0 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Asset0?.setOrganization) {
|
|
await Asset0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset1 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Asset1?.setOrganization) {
|
|
await Asset1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset2 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Asset2?.setOrganization) {
|
|
await Asset2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset3 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Asset3?.setOrganization) {
|
|
await Asset3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateAttendanceRecordWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const AttendanceRecord0 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (AttendanceRecord0?.setEmployee) {
|
|
await AttendanceRecord0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const AttendanceRecord1 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (AttendanceRecord1?.setEmployee) {
|
|
await AttendanceRecord1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const AttendanceRecord2 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (AttendanceRecord2?.setEmployee) {
|
|
await AttendanceRecord2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const AttendanceRecord3 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (AttendanceRecord3?.setEmployee) {
|
|
await AttendanceRecord3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateAttendanceRecordWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const AttendanceRecord0 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (AttendanceRecord0?.setOrganization) {
|
|
await AttendanceRecord0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const AttendanceRecord1 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (AttendanceRecord1?.setOrganization) {
|
|
await AttendanceRecord1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const AttendanceRecord2 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (AttendanceRecord2?.setOrganization) {
|
|
await AttendanceRecord2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const AttendanceRecord3 = await AttendanceRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (AttendanceRecord3?.setOrganization) {
|
|
await AttendanceRecord3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateCommunicationWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Communication0 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Communication0?.setEmployee) {
|
|
await Communication0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Communication1 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Communication1?.setEmployee) {
|
|
await Communication1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Communication2 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Communication2?.setEmployee) {
|
|
await Communication2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Communication3 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Communication3?.setEmployee) {
|
|
await Communication3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateCommunicationWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Communication0 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Communication0?.setOrganization) {
|
|
await Communication0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Communication1 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Communication1?.setOrganization) {
|
|
await Communication1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Communication2 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Communication2?.setOrganization) {
|
|
await Communication2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Communication3 = await Communications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Communication3?.setOrganization) {
|
|
await Communication3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateCompensationWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Compensation0 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Compensation0?.setEmployee) {
|
|
await Compensation0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Compensation1 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Compensation1?.setEmployee) {
|
|
await Compensation1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Compensation2 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Compensation2?.setEmployee) {
|
|
await Compensation2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Compensation3 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Compensation3?.setEmployee) {
|
|
await Compensation3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateCompensationWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Compensation0 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Compensation0?.setOrganization) {
|
|
await Compensation0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Compensation1 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Compensation1?.setOrganization) {
|
|
await Compensation1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Compensation2 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Compensation2?.setOrganization) {
|
|
await Compensation2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Compensation3 = await Compensations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Compensation3?.setOrganization) {
|
|
await Compensation3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateComplianceDocumentWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ComplianceDocument0 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ComplianceDocument0?.setEmployee) {
|
|
await ComplianceDocument0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ComplianceDocument1 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ComplianceDocument1?.setEmployee) {
|
|
await ComplianceDocument1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ComplianceDocument2 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ComplianceDocument2?.setEmployee) {
|
|
await ComplianceDocument2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ComplianceDocument3 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ComplianceDocument3?.setEmployee) {
|
|
await ComplianceDocument3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateComplianceDocumentWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ComplianceDocument0 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ComplianceDocument0?.setOrganization) {
|
|
await ComplianceDocument0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ComplianceDocument1 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ComplianceDocument1?.setOrganization) {
|
|
await ComplianceDocument1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ComplianceDocument2 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ComplianceDocument2?.setOrganization) {
|
|
await ComplianceDocument2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ComplianceDocument3 = await ComplianceDocuments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ComplianceDocument3?.setOrganization) {
|
|
await ComplianceDocument3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateEmployeeWithJob_detail() {
|
|
const relatedJob_detail0 = await JobDetails.findOne({
|
|
offset: Math.floor(Math.random() * (await JobDetails.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setJob_detail) {
|
|
await Employee0.setJob_detail(relatedJob_detail0);
|
|
}
|
|
|
|
const relatedJob_detail1 = await JobDetails.findOne({
|
|
offset: Math.floor(Math.random() * (await JobDetails.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setJob_detail) {
|
|
await Employee1.setJob_detail(relatedJob_detail1);
|
|
}
|
|
|
|
const relatedJob_detail2 = await JobDetails.findOne({
|
|
offset: Math.floor(Math.random() * (await JobDetails.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setJob_detail) {
|
|
await Employee2.setJob_detail(relatedJob_detail2);
|
|
}
|
|
|
|
const relatedJob_detail3 = await JobDetails.findOne({
|
|
offset: Math.floor(Math.random() * (await JobDetails.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setJob_detail) {
|
|
await Employee3.setJob_detail(relatedJob_detail3);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateEmployeeWithCompensation() {
|
|
const relatedCompensation0 = await Compensations.findOne({
|
|
offset: Math.floor(Math.random() * (await Compensations.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setCompensation) {
|
|
await Employee0.setCompensation(relatedCompensation0);
|
|
}
|
|
|
|
const relatedCompensation1 = await Compensations.findOne({
|
|
offset: Math.floor(Math.random() * (await Compensations.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setCompensation) {
|
|
await Employee1.setCompensation(relatedCompensation1);
|
|
}
|
|
|
|
const relatedCompensation2 = await Compensations.findOne({
|
|
offset: Math.floor(Math.random() * (await Compensations.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setCompensation) {
|
|
await Employee2.setCompensation(relatedCompensation2);
|
|
}
|
|
|
|
const relatedCompensation3 = await Compensations.findOne({
|
|
offset: Math.floor(Math.random() * (await Compensations.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setCompensation) {
|
|
await Employee3.setCompensation(relatedCompensation3);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateEmployeeWithExit_information() {
|
|
const relatedExit_information0 = await ExitInformation.findOne({
|
|
offset: Math.floor(Math.random() * (await ExitInformation.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setExit_information) {
|
|
await Employee0.setExit_information(relatedExit_information0);
|
|
}
|
|
|
|
const relatedExit_information1 = await ExitInformation.findOne({
|
|
offset: Math.floor(Math.random() * (await ExitInformation.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setExit_information) {
|
|
await Employee1.setExit_information(relatedExit_information1);
|
|
}
|
|
|
|
const relatedExit_information2 = await ExitInformation.findOne({
|
|
offset: Math.floor(Math.random() * (await ExitInformation.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setExit_information) {
|
|
await Employee2.setExit_information(relatedExit_information2);
|
|
}
|
|
|
|
const relatedExit_information3 = await ExitInformation.findOne({
|
|
offset: Math.floor(Math.random() * (await ExitInformation.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setExit_information) {
|
|
await Employee3.setExit_information(relatedExit_information3);
|
|
}
|
|
}
|
|
|
|
async function associateEmployeeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setOrganization) {
|
|
await Employee0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setOrganization) {
|
|
await Employee1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setOrganization) {
|
|
await Employee2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setOrganization) {
|
|
await Employee3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateExitInformationWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ExitInformation0 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ExitInformation0?.setEmployee) {
|
|
await ExitInformation0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ExitInformation1 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ExitInformation1?.setEmployee) {
|
|
await ExitInformation1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ExitInformation2 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ExitInformation2?.setEmployee) {
|
|
await ExitInformation2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ExitInformation3 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ExitInformation3?.setEmployee) {
|
|
await ExitInformation3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateExitInformationWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ExitInformation0 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ExitInformation0?.setOrganization) {
|
|
await ExitInformation0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ExitInformation1 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ExitInformation1?.setOrganization) {
|
|
await ExitInformation1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ExitInformation2 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ExitInformation2?.setOrganization) {
|
|
await ExitInformation2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ExitInformation3 = await ExitInformation.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ExitInformation3?.setOrganization) {
|
|
await ExitInformation3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateHealthRecordWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const HealthRecord0 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (HealthRecord0?.setEmployee) {
|
|
await HealthRecord0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const HealthRecord1 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (HealthRecord1?.setEmployee) {
|
|
await HealthRecord1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const HealthRecord2 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (HealthRecord2?.setEmployee) {
|
|
await HealthRecord2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const HealthRecord3 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (HealthRecord3?.setEmployee) {
|
|
await HealthRecord3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateHealthRecordWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HealthRecord0 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (HealthRecord0?.setOrganization) {
|
|
await HealthRecord0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HealthRecord1 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (HealthRecord1?.setOrganization) {
|
|
await HealthRecord1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HealthRecord2 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (HealthRecord2?.setOrganization) {
|
|
await HealthRecord2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HealthRecord3 = await HealthRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (HealthRecord3?.setOrganization) {
|
|
await HealthRecord3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateJobDetailWithManager() {
|
|
const relatedManager0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const JobDetail0 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (JobDetail0?.setManager) {
|
|
await JobDetail0.setManager(relatedManager0);
|
|
}
|
|
|
|
const relatedManager1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const JobDetail1 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (JobDetail1?.setManager) {
|
|
await JobDetail1.setManager(relatedManager1);
|
|
}
|
|
|
|
const relatedManager2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const JobDetail2 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (JobDetail2?.setManager) {
|
|
await JobDetail2.setManager(relatedManager2);
|
|
}
|
|
|
|
const relatedManager3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const JobDetail3 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (JobDetail3?.setManager) {
|
|
await JobDetail3.setManager(relatedManager3);
|
|
}
|
|
}
|
|
|
|
async function associateJobDetailWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const JobDetail0 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (JobDetail0?.setOrganization) {
|
|
await JobDetail0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const JobDetail1 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (JobDetail1?.setOrganization) {
|
|
await JobDetail1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const JobDetail2 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (JobDetail2?.setOrganization) {
|
|
await JobDetail2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const JobDetail3 = await JobDetails.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (JobDetail3?.setOrganization) {
|
|
await JobDetail3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associatePerformanceReviewWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const PerformanceReview0 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PerformanceReview0?.setEmployee) {
|
|
await PerformanceReview0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const PerformanceReview1 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PerformanceReview1?.setEmployee) {
|
|
await PerformanceReview1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const PerformanceReview2 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PerformanceReview2?.setEmployee) {
|
|
await PerformanceReview2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const PerformanceReview3 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PerformanceReview3?.setEmployee) {
|
|
await PerformanceReview3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associatePerformanceReviewWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PerformanceReview0 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PerformanceReview0?.setOrganization) {
|
|
await PerformanceReview0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PerformanceReview1 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PerformanceReview1?.setOrganization) {
|
|
await PerformanceReview1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PerformanceReview2 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PerformanceReview2?.setOrganization) {
|
|
await PerformanceReview2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PerformanceReview3 = await PerformanceReviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PerformanceReview3?.setOrganization) {
|
|
await PerformanceReview3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
async function associateProfessionalDevelopmentWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ProfessionalDevelopment0 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ProfessionalDevelopment0?.setEmployee) {
|
|
await ProfessionalDevelopment0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ProfessionalDevelopment1 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ProfessionalDevelopment1?.setEmployee) {
|
|
await ProfessionalDevelopment1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ProfessionalDevelopment2 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ProfessionalDevelopment2?.setEmployee) {
|
|
await ProfessionalDevelopment2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const ProfessionalDevelopment3 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ProfessionalDevelopment3?.setEmployee) {
|
|
await ProfessionalDevelopment3.setEmployee(relatedEmployee3);
|
|
}
|
|
}
|
|
|
|
async function associateProfessionalDevelopmentWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ProfessionalDevelopment0 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ProfessionalDevelopment0?.setOrganization) {
|
|
await ProfessionalDevelopment0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ProfessionalDevelopment1 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ProfessionalDevelopment1?.setOrganization) {
|
|
await ProfessionalDevelopment1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ProfessionalDevelopment2 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ProfessionalDevelopment2?.setOrganization) {
|
|
await ProfessionalDevelopment2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ProfessionalDevelopment3 = await ProfessionalDevelopment.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ProfessionalDevelopment3?.setOrganization) {
|
|
await ProfessionalDevelopment3.setOrganization(relatedOrganization3);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Assets.bulkCreate(AssetsData);
|
|
|
|
await AttendanceRecords.bulkCreate(AttendanceRecordsData);
|
|
|
|
await Communications.bulkCreate(CommunicationsData);
|
|
|
|
await Compensations.bulkCreate(CompensationsData);
|
|
|
|
await ComplianceDocuments.bulkCreate(ComplianceDocumentsData);
|
|
|
|
await Employees.bulkCreate(EmployeesData);
|
|
|
|
await ExitInformation.bulkCreate(ExitInformationData);
|
|
|
|
await HealthRecords.bulkCreate(HealthRecordsData);
|
|
|
|
await JobDetails.bulkCreate(JobDetailsData);
|
|
|
|
await PerformanceReviews.bulkCreate(PerformanceReviewsData);
|
|
|
|
await ProfessionalDevelopment.bulkCreate(ProfessionalDevelopmentData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateAssetWithEmployee(),
|
|
|
|
await associateAssetWithOrganization(),
|
|
|
|
await associateAttendanceRecordWithEmployee(),
|
|
|
|
await associateAttendanceRecordWithOrganization(),
|
|
|
|
await associateCommunicationWithEmployee(),
|
|
|
|
await associateCommunicationWithOrganization(),
|
|
|
|
await associateCompensationWithEmployee(),
|
|
|
|
await associateCompensationWithOrganization(),
|
|
|
|
await associateComplianceDocumentWithEmployee(),
|
|
|
|
await associateComplianceDocumentWithOrganization(),
|
|
|
|
await associateEmployeeWithJob_detail(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateEmployeeWithCompensation(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateEmployeeWithExit_information(),
|
|
|
|
await associateEmployeeWithOrganization(),
|
|
|
|
await associateExitInformationWithEmployee(),
|
|
|
|
await associateExitInformationWithOrganization(),
|
|
|
|
await associateHealthRecordWithEmployee(),
|
|
|
|
await associateHealthRecordWithOrganization(),
|
|
|
|
await associateJobDetailWithManager(),
|
|
|
|
await associateJobDetailWithOrganization(),
|
|
|
|
await associatePerformanceReviewWithEmployee(),
|
|
|
|
await associatePerformanceReviewWithOrganization(),
|
|
|
|
await associateProfessionalDevelopmentWithEmployee(),
|
|
|
|
await associateProfessionalDevelopmentWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('assets', null, {});
|
|
|
|
await queryInterface.bulkDelete('attendance_records', null, {});
|
|
|
|
await queryInterface.bulkDelete('communications', null, {});
|
|
|
|
await queryInterface.bulkDelete('compensations', null, {});
|
|
|
|
await queryInterface.bulkDelete('compliance_documents', null, {});
|
|
|
|
await queryInterface.bulkDelete('employees', null, {});
|
|
|
|
await queryInterface.bulkDelete('exit_information', null, {});
|
|
|
|
await queryInterface.bulkDelete('health_records', null, {});
|
|
|
|
await queryInterface.bulkDelete('job_details', null, {});
|
|
|
|
await queryInterface.bulkDelete('performance_reviews', null, {});
|
|
|
|
await queryInterface.bulkDelete('professional_development', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|