const db = require('../models'); const Users = db.users; const Candidates = db.candidates; const Communications = db.communications; const JobRoles = db.job_roles; const Clients = db.clients; const CandidatesData = [ { full_name: 'Alice Johnson', linkedin_url: 'https://linkedin.com/in/alicejohnson', current_company: 'TechCorp', job_title: 'Software Engineer', past_companies: 'Innovatech, CodeWorks', experience: '5 years', education: 'B.Sc. Computer Science', skills: 'JavaScript, React, Node.js', profile_picture: 'https://example.com/images/alice.jpg', location: 'New York, NY', industry: 'Technology', about: 'Experienced software engineer with a passion for developing innovative programs.', status: 'Rejected', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'Bob Smith', linkedin_url: 'https://linkedin.com/in/bsmith', current_company: 'DataSolutions', job_title: 'Data Analyst', past_companies: 'DataCorp, AnalyticsPro', experience: '3 years', education: 'M.Sc. Data Science', skills: 'Python, SQL, Tableau', profile_picture: 'https://example.com/images/bob.jpg', location: 'San Francisco, CA', industry: 'Data Analytics', about: 'Data analyst with expertise in data visualization and statistical analysis.', status: 'Applied', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'Catherine Lee', linkedin_url: 'https://linkedin.com/in/clee', current_company: 'HealthTech', job_title: 'Project Manager', past_companies: 'MedSolutions, HealthPro', experience: '7 years', education: 'MBA', skills: 'Project Management, Agile, Scrum', profile_picture: 'https://example.com/images/catherine.jpg', location: 'Boston, MA', industry: 'Healthcare', about: 'Project manager with a focus on healthcare technology projects.', status: 'Applied', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'David Brown', linkedin_url: 'https://linkedin.com/in/dbrown', current_company: 'FinTech Innovations', job_title: 'Financial Analyst', past_companies: 'FinanceCorp, MoneyMatters', experience: '4 years', education: 'B.A. Finance', skills: 'Financial Modeling, Excel, Risk Analysis', profile_picture: 'https://example.com/images/david.jpg', location: 'Chicago, IL', industry: 'Finance', about: 'Financial analyst with a strong background in financial modeling and risk analysis.', status: 'Interviewing', // type code here for "relation_one" field // type code here for "relation_one" field }, ]; const CommunicationsData = [ { // type code here for "relation_one" field message: 'Follow-up email sent regarding interview schedule.', timestamp: new Date('2023-10-01T10:00:00Z'), // type code here for "relation_one" field }, { // type code here for "relation_one" field message: 'Initial contact made via LinkedIn.', timestamp: new Date('2023-10-02T11:30:00Z'), // type code here for "relation_one" field }, { // type code here for "relation_one" field message: 'Feedback received from hiring manager.', timestamp: new Date('2023-10-03T09:15:00Z'), // type code here for "relation_one" field }, { // type code here for "relation_one" field message: 'Rejection email sent after final interview.', timestamp: new Date('2023-10-04T14:45:00Z'), // type code here for "relation_one" field }, ]; const JobRolesData = [ { title: 'Frontend Developer', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Data Analyst', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Project Manager', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field }, { title: 'Financial Analyst', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field }, ]; const ClientsData = [ { name: 'TechCorp', }, { name: 'DataSolutions', }, { name: 'HealthTech', }, { name: 'FinTech Innovations', }, ]; // Similar logic for "relation_many" async function associateUserWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const User0 = await Users.findOne({ order: [['id', 'ASC']], offset: 0, }); if (User0?.setClient) { await User0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const User1 = await Users.findOne({ order: [['id', 'ASC']], offset: 1, }); if (User1?.setClient) { await User1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const User2 = await Users.findOne({ order: [['id', 'ASC']], offset: 2, }); if (User2?.setClient) { await User2.setClient(relatedClient2); } const relatedClient3 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const User3 = await Users.findOne({ order: [['id', 'ASC']], offset: 3, }); if (User3?.setClient) { await User3.setClient(relatedClient3); } } async function associateCandidateWithJob_role() { const relatedJob_role0 = await JobRoles.findOne({ offset: Math.floor(Math.random() * (await JobRoles.count())), }); const Candidate0 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Candidate0?.setJob_role) { await Candidate0.setJob_role(relatedJob_role0); } const relatedJob_role1 = await JobRoles.findOne({ offset: Math.floor(Math.random() * (await JobRoles.count())), }); const Candidate1 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Candidate1?.setJob_role) { await Candidate1.setJob_role(relatedJob_role1); } const relatedJob_role2 = await JobRoles.findOne({ offset: Math.floor(Math.random() * (await JobRoles.count())), }); const Candidate2 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Candidate2?.setJob_role) { await Candidate2.setJob_role(relatedJob_role2); } const relatedJob_role3 = await JobRoles.findOne({ offset: Math.floor(Math.random() * (await JobRoles.count())), }); const Candidate3 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Candidate3?.setJob_role) { await Candidate3.setJob_role(relatedJob_role3); } } async function associateCandidateWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Candidate0 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Candidate0?.setClient) { await Candidate0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Candidate1 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Candidate1?.setClient) { await Candidate1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Candidate2 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Candidate2?.setClient) { await Candidate2.setClient(relatedClient2); } const relatedClient3 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Candidate3 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Candidate3?.setClient) { await Candidate3.setClient(relatedClient3); } } async function associateCommunicationWithCandidate() { const relatedCandidate0 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Communication0 = await Communications.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Communication0?.setCandidate) { await Communication0.setCandidate(relatedCandidate0); } const relatedCandidate1 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Communication1 = await Communications.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Communication1?.setCandidate) { await Communication1.setCandidate(relatedCandidate1); } const relatedCandidate2 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Communication2 = await Communications.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Communication2?.setCandidate) { await Communication2.setCandidate(relatedCandidate2); } const relatedCandidate3 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Communication3 = await Communications.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Communication3?.setCandidate) { await Communication3.setCandidate(relatedCandidate3); } } async function associateCommunicationWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Communication0 = await Communications.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Communication0?.setClient) { await Communication0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Communication1 = await Communications.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Communication1?.setClient) { await Communication1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Communication2 = await Communications.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Communication2?.setClient) { await Communication2.setClient(relatedClient2); } const relatedClient3 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Communication3 = await Communications.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Communication3?.setClient) { await Communication3.setClient(relatedClient3); } } async function associateJobRoleWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole0 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 0, }); if (JobRole0?.setClient) { await JobRole0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole1 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 1, }); if (JobRole1?.setClient) { await JobRole1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole2 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 2, }); if (JobRole2?.setClient) { await JobRole2.setClient(relatedClient2); } const relatedClient3 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole3 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 3, }); if (JobRole3?.setClient) { await JobRole3.setClient(relatedClient3); } } // Similar logic for "relation_many" async function associateJobRoleWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole0 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 0, }); if (JobRole0?.setClient) { await JobRole0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole1 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 1, }); if (JobRole1?.setClient) { await JobRole1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole2 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 2, }); if (JobRole2?.setClient) { await JobRole2.setClient(relatedClient2); } const relatedClient3 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const JobRole3 = await JobRoles.findOne({ order: [['id', 'ASC']], offset: 3, }); if (JobRole3?.setClient) { await JobRole3.setClient(relatedClient3); } } module.exports = { up: async (queryInterface, Sequelize) => { await Candidates.bulkCreate(CandidatesData); await Communications.bulkCreate(CommunicationsData); await JobRoles.bulkCreate(JobRolesData); await Clients.bulkCreate(ClientsData); await Promise.all([ // Similar logic for "relation_many" await associateUserWithClient(), await associateCandidateWithJob_role(), await associateCandidateWithClient(), await associateCommunicationWithCandidate(), await associateCommunicationWithClient(), await associateJobRoleWithClient(), // Similar logic for "relation_many" await associateJobRoleWithClient(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('candidates', null, {}); await queryInterface.bulkDelete('communications', null, {}); await queryInterface.bulkDelete('job_roles', null, {}); await queryInterface.bulkDelete('clients', null, {}); }, };