const db = require('../models'); const Users = db.users; const PharmacyInfo = db.pharmacy_info; const Products = db.products; const Quotations = db.quotations; const Services = db.services; const PharmacyInfoData = [ { about: 'We are a community-focused pharmacy providing quality healthcare products.', contact_details: '123 Main St, Anytown, USA. Phone: (123) 456-7890', history: 'Established in 1990, we have been serving the community for over 30 years.', // type code here for "relation_many" field }, { about: 'Your trusted partner in health and wellness.', contact_details: '456 Elm St, Othertown, USA. Phone: (987) 654-3210', history: 'Founded in 2000, we pride ourselves on personalized service.', // type code here for "relation_many" field }, { about: 'Marie Curie', contact_details: 'Edwin Hubble', history: 'Paul Ehrlich', // type code here for "relation_many" field }, { about: 'Leonard Euler', contact_details: 'Pierre Simon de Laplace', history: 'Sigmund Freud', // type code here for "relation_many" field }, ]; const ProductsData = [ { product_name: 'Aspirin', description: 'Pain reliever and anti-inflammatory medication.', price: 5.99, // type code here for "images" field }, { product_name: 'Vitamin C', description: 'Boosts immune system and improves skin health.', price: 12.49, // type code here for "images" field }, { product_name: 'Cough Syrup', description: 'Relieves cough and throat irritation.', price: 8.75, // type code here for "images" field }, { product_name: 'Pain Relief Patch', description: 'Provides temporary relief from minor aches and pains.', price: 3.5, // type code here for "images" field }, ]; const QuotationsData = [ { requester_name: 'Alice Johnson', requester_email: 'alice.johnson@example.com', request_details: 'Request for 100 units of aspirin.', submitted_at: new Date('2023-10-01T10:00:00Z'), // type code here for "relation_one" field }, { requester_name: 'Bob Williams', requester_email: 'bob.williams@example.com', request_details: 'Inquiry about bulk purchase of vitamins.', submitted_at: new Date('2023-10-02T11:30:00Z'), // type code here for "relation_one" field }, { requester_name: 'Charlie Brown', requester_email: 'charlie.brown@example.com', request_details: 'Quotation for 50 units of cough syrup.', submitted_at: new Date('2023-10-03T09:15:00Z'), // type code here for "relation_one" field }, { requester_name: 'Diana Prince', requester_email: 'diana.prince@example.com', request_details: 'Request for pricing on pain relief patches.', submitted_at: new Date('2023-10-04T14:45:00Z'), // type code here for "relation_one" field }, ]; const ServicesData = [ { service_name: 'Prescription Services', description: 'Filling and managing prescriptions with care and accuracy.', }, { service_name: 'Health Consultations', description: 'Professional advice and consultations for your health needs.', }, { service_name: 'Over-the-Counter Medications', description: 'Wide range of OTC medications available.', }, { service_name: 'Nutritional Advice', description: 'Guidance on vitamins and supplements for better health.', }, ]; // Similar logic for "relation_many" // Similar logic for "relation_many" async function associateQuotationWithHandled_by() { const relatedHandled_by0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Quotation0 = await Quotations.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Quotation0?.setHandled_by) { await Quotation0.setHandled_by(relatedHandled_by0); } const relatedHandled_by1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Quotation1 = await Quotations.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Quotation1?.setHandled_by) { await Quotation1.setHandled_by(relatedHandled_by1); } const relatedHandled_by2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Quotation2 = await Quotations.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Quotation2?.setHandled_by) { await Quotation2.setHandled_by(relatedHandled_by2); } const relatedHandled_by3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Quotation3 = await Quotations.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Quotation3?.setHandled_by) { await Quotation3.setHandled_by(relatedHandled_by3); } } module.exports = { up: async (queryInterface, Sequelize) => { await PharmacyInfo.bulkCreate(PharmacyInfoData); await Products.bulkCreate(ProductsData); await Quotations.bulkCreate(QuotationsData); await Services.bulkCreate(ServicesData); await Promise.all([ // Similar logic for "relation_many" // Similar logic for "relation_many" await associateQuotationWithHandled_by(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('pharmacy_info', null, {}); await queryInterface.bulkDelete('products', null, {}); await queryInterface.bulkDelete('quotations', null, {}); await queryInterface.bulkDelete('services', null, {}); }, };