const db = require('../models'); const Users = db.users; const Candidates = db.candidates; const Projects = db.projects; const Reports = db.reports; const Clients = db.clients; const CandidatesData = [ { name: 'Alice Johnson', email: 'alice.johnson@example.com', // type code here for "relation_one" field // type code here for "files" field // type code here for "files" field interview_transcript: 'Max Delbruck', // type code here for "files" field // type code here for "relation_one" field }, { name: 'Bob Martin', email: 'bob.martin@example.com', // type code here for "relation_one" field // type code here for "files" field // type code here for "files" field interview_transcript: 'Edward Teller', // type code here for "files" field // type code here for "relation_one" field }, { name: 'Charlie Davis', email: 'charlie.davis@example.com', // type code here for "relation_one" field // type code here for "files" field // type code here for "files" field interview_transcript: 'Claude Levi-Strauss', // type code here for "files" field // type code here for "relation_one" field }, ]; const ProjectsData = [ { title: 'AI Recruitment System', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "files" field job_description: 'Jonas Salk', strategic_form: 'Claude Levi-Strauss', interview_type: 'in_person', // type code here for "relation_one" field }, { title: 'Remote Interview Platform', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "files" field job_description: 'Archimedes', strategic_form: 'Pierre Simon de Laplace', interview_type: 'remote', // type code here for "relation_one" field }, { title: 'Candidate Assessment Tool', // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "files" field job_description: 'Frederick Gowland Hopkins', strategic_form: 'Emil Fischer', interview_type: 'remote', // type code here for "relation_one" field }, ]; const ReportsData = [ { // type code here for "relation_one" field content: 'Comprehensive analysis of skills and competencies.', // type code here for "relation_one" field }, { // type code here for "relation_one" field content: 'Detailed report on interview performance.', // type code here for "relation_one" field }, { // type code here for "relation_one" field content: 'Assessment of technical knowledge and problem-solving.', // type code here for "relation_one" field }, ]; const ClientsData = [ { name: 'Tech Solutions Inc.', }, { name: 'Innovatech Corp.', }, { name: 'Future Enterprises', }, ]; // 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); } } async function associateCandidateWithProject() { const relatedProject0 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Candidate0 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Candidate0?.setProject) { await Candidate0.setProject(relatedProject0); } const relatedProject1 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Candidate1 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Candidate1?.setProject) { await Candidate1.setProject(relatedProject1); } const relatedProject2 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Candidate2 = await Candidates.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Candidate2?.setProject) { await Candidate2.setProject(relatedProject2); } } 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); } } async function associateProjectWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project0 = await Projects.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Project0?.setClient) { await Project0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project1 = await Projects.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Project1?.setClient) { await Project1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project2 = await Projects.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Project2?.setClient) { await Project2.setClient(relatedClient2); } } // Similar logic for "relation_many" async function associateProjectWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project0 = await Projects.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Project0?.setClient) { await Project0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project1 = await Projects.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Project1?.setClient) { await Project1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Project2 = await Projects.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Project2?.setClient) { await Project2.setClient(relatedClient2); } } async function associateReportWithCandidate() { const relatedCandidate0 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Report0 = await Reports.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Report0?.setCandidate) { await Report0.setCandidate(relatedCandidate0); } const relatedCandidate1 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Report1 = await Reports.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Report1?.setCandidate) { await Report1.setCandidate(relatedCandidate1); } const relatedCandidate2 = await Candidates.findOne({ offset: Math.floor(Math.random() * (await Candidates.count())), }); const Report2 = await Reports.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Report2?.setCandidate) { await Report2.setCandidate(relatedCandidate2); } } async function associateReportWithClient() { const relatedClient0 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Report0 = await Reports.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Report0?.setClient) { await Report0.setClient(relatedClient0); } const relatedClient1 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Report1 = await Reports.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Report1?.setClient) { await Report1.setClient(relatedClient1); } const relatedClient2 = await Clients.findOne({ offset: Math.floor(Math.random() * (await Clients.count())), }); const Report2 = await Reports.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Report2?.setClient) { await Report2.setClient(relatedClient2); } } module.exports = { up: async (queryInterface, Sequelize) => { await Candidates.bulkCreate(CandidatesData); await Projects.bulkCreate(ProjectsData); await Reports.bulkCreate(ReportsData); await Clients.bulkCreate(ClientsData); await Promise.all([ // Similar logic for "relation_many" await associateUserWithClient(), await associateCandidateWithProject(), await associateCandidateWithClient(), await associateProjectWithClient(), // Similar logic for "relation_many" await associateProjectWithClient(), await associateReportWithCandidate(), await associateReportWithClient(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('candidates', null, {}); await queryInterface.bulkDelete('projects', null, {}); await queryInterface.bulkDelete('reports', null, {}); await queryInterface.bulkDelete('clients', null, {}); }, };