256 lines
5.3 KiB
JavaScript
256 lines
5.3 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Clients = db.clients;
|
|
|
|
const Leads = db.leads;
|
|
|
|
const Services = db.services;
|
|
|
|
const Workflows = db.workflows;
|
|
|
|
const ClientsData = [
|
|
{
|
|
company_name: 'Tech Innovators Inc.',
|
|
|
|
contact_person: 'John Doe',
|
|
|
|
email: 'john.doe@techinnovators.com',
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Retail Solutions Ltd.',
|
|
|
|
contact_person: 'Jane Smith',
|
|
|
|
email: 'jane.smith@retailsolutions.com',
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Healthcare AI Partners',
|
|
|
|
contact_person: 'Emily Johnson',
|
|
|
|
email: 'emily.johnson@healthcareai.com',
|
|
|
|
// type code here for "relation_many" field
|
|
},
|
|
];
|
|
|
|
const LeadsData = [
|
|
{
|
|
name: 'Alice Green',
|
|
|
|
email: 'alice.green@potentialclient.com',
|
|
|
|
status: 'Contacted',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Bob White',
|
|
|
|
email: 'bob.white@potentialclient.com',
|
|
|
|
status: 'New',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Charlie Black',
|
|
|
|
email: 'charlie.black@potentialclient.com',
|
|
|
|
status: 'Qualified',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ServicesData = [
|
|
{
|
|
name: 'AI Strategy & Consulting',
|
|
|
|
description:
|
|
'Comprehensive AI strategy development and consulting services.',
|
|
|
|
price: 5000,
|
|
|
|
category: 'AIIntegration&Automation',
|
|
},
|
|
|
|
{
|
|
name: 'Custom AI Development',
|
|
|
|
description: 'Tailored AI solutions for specific business needs.',
|
|
|
|
price: 10000,
|
|
|
|
category: 'GenerativeAISolutions',
|
|
},
|
|
|
|
{
|
|
name: 'Generative AI Solutions',
|
|
|
|
description: 'Advanced generative AI tools for content creation.',
|
|
|
|
price: 7500,
|
|
|
|
category: 'AIDataServices',
|
|
},
|
|
];
|
|
|
|
const WorkflowsData = [
|
|
{
|
|
name: 'Retail Automation Workflow',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
start_date: new Date('2023-11-01T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-12-01T17:00:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Healthcare Data Processing',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
start_date: new Date('2023-10-15T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-15T17:00:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Finance Risk Assessment',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
start_date: new Date('2023-09-01T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-01T17:00:00Z'),
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateLeadWithInterested_service() {
|
|
const relatedInterested_service0 = await Services.findOne({
|
|
offset: Math.floor(Math.random() * (await Services.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Lead0?.setInterested_service) {
|
|
await Lead0.setInterested_service(relatedInterested_service0);
|
|
}
|
|
|
|
const relatedInterested_service1 = await Services.findOne({
|
|
offset: Math.floor(Math.random() * (await Services.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Lead1?.setInterested_service) {
|
|
await Lead1.setInterested_service(relatedInterested_service1);
|
|
}
|
|
|
|
const relatedInterested_service2 = await Services.findOne({
|
|
offset: Math.floor(Math.random() * (await Services.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Lead2?.setInterested_service) {
|
|
await Lead2.setInterested_service(relatedInterested_service2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkflowWithClient() {
|
|
const relatedClient0 = await Clients.findOne({
|
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
});
|
|
const Workflow0 = await Workflows.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Workflow0?.setClient) {
|
|
await Workflow0.setClient(relatedClient0);
|
|
}
|
|
|
|
const relatedClient1 = await Clients.findOne({
|
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
});
|
|
const Workflow1 = await Workflows.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Workflow1?.setClient) {
|
|
await Workflow1.setClient(relatedClient1);
|
|
}
|
|
|
|
const relatedClient2 = await Clients.findOne({
|
|
offset: Math.floor(Math.random() * (await Clients.count())),
|
|
});
|
|
const Workflow2 = await Workflows.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Workflow2?.setClient) {
|
|
await Workflow2.setClient(relatedClient2);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Clients.bulkCreate(ClientsData);
|
|
|
|
await Leads.bulkCreate(LeadsData);
|
|
|
|
await Services.bulkCreate(ServicesData);
|
|
|
|
await Workflows.bulkCreate(WorkflowsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateLeadWithInterested_service(),
|
|
|
|
await associateWorkflowWithClient(),
|
|
|
|
// Similar logic for "relation_many"
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('clients', null, {});
|
|
|
|
await queryInterface.bulkDelete('leads', null, {});
|
|
|
|
await queryInterface.bulkDelete('services', null, {});
|
|
|
|
await queryInterface.bulkDelete('workflows', null, {});
|
|
},
|
|
};
|