784 lines
18 KiB
JavaScript
784 lines
18 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const HumanResources = db.human_resources;
|
|
|
|
const Inventory = db.inventory;
|
|
|
|
const Machinery = db.machinery;
|
|
|
|
const QualityControl = db.quality_control;
|
|
|
|
const RawMaterials = db.raw_materials;
|
|
|
|
const Subsidiaries = db.subsidiaries;
|
|
|
|
const Suppliers = db.suppliers;
|
|
|
|
const WorkOrders = db.work_orders;
|
|
|
|
const Subsidiary = db.subsidiary;
|
|
|
|
const HumanResourcesData = [
|
|
{
|
|
employee_name: 'John Doe',
|
|
|
|
role: 'skilled_labor',
|
|
|
|
shift: 'Day',
|
|
|
|
payroll: 50000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
employee_name: 'Jane Smith',
|
|
|
|
role: 'managerial_staff',
|
|
|
|
shift: 'Night',
|
|
|
|
payroll: 75000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
employee_name: 'Alice Johnson',
|
|
|
|
role: 'managerial_staff',
|
|
|
|
shift: 'Day',
|
|
|
|
payroll: 52000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const InventoryData = [
|
|
{
|
|
product_name: 'Widget A',
|
|
|
|
available_quantity: 200,
|
|
|
|
reserved_quantity: 50,
|
|
|
|
returned_quantity: 10,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
product_name: 'Gadget B',
|
|
|
|
available_quantity: 150,
|
|
|
|
reserved_quantity: 30,
|
|
|
|
returned_quantity: 5,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
product_name: 'Device C',
|
|
|
|
available_quantity: 300,
|
|
|
|
reserved_quantity: 70,
|
|
|
|
returned_quantity: 20,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const MachineryData = [
|
|
{
|
|
machine_name: 'CNC Lathe',
|
|
|
|
maintenance_schedule: new Date('2023-12-01T10:00:00Z'),
|
|
|
|
downtime_hours: 5,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
machine_name: 'Injection Molder',
|
|
|
|
maintenance_schedule: new Date('2023-12-05T10:00:00Z'),
|
|
|
|
downtime_hours: 3,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
machine_name: 'Laser Cutter',
|
|
|
|
maintenance_schedule: new Date('2023-12-10T10:00:00Z'),
|
|
|
|
downtime_hours: 2,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const QualityControlData = [
|
|
{
|
|
check_name: 'Initial Inspection',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
compliance: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
check_name: 'Mid-Process Check',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
compliance: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
check_name: 'Final Inspection',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
compliance: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const RawMaterialsData = [
|
|
{
|
|
material_name: 'Steel Rods',
|
|
|
|
quantity: 500,
|
|
|
|
reorder_level: 100,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
material_name: 'Copper Wires',
|
|
|
|
quantity: 300,
|
|
|
|
reorder_level: 50,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
material_name: 'Plastic Sheets',
|
|
|
|
quantity: 1000,
|
|
|
|
reorder_level: 200,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SubsidiariesData = [
|
|
{
|
|
name: 'Edwin Hubble',
|
|
|
|
address: 'Euclid',
|
|
|
|
contact_number: 'Frederick Sanger',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Euclid',
|
|
|
|
address: 'Andreas Vesalius',
|
|
|
|
contact_number: 'Ernst Haeckel',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Lucretius',
|
|
|
|
address: 'Neils Bohr',
|
|
|
|
contact_number: 'Edward O. Wilson',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SuppliersData = [
|
|
{
|
|
supplier_name: 'Global Metals Inc.',
|
|
|
|
contract_terms: 'Annual',
|
|
|
|
delivery_schedule: new Date('2023-11-30T09:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
supplier_name: 'Plastics Plus',
|
|
|
|
contract_terms: 'Bi-Annual',
|
|
|
|
delivery_schedule: new Date('2023-12-15T09:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
supplier_name: 'Copper Connections',
|
|
|
|
contract_terms: 'Quarterly',
|
|
|
|
delivery_schedule: new Date('2023-12-01T09:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const WorkOrdersData = [
|
|
{
|
|
order_number: 'WO-001',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-11-01T08:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-05T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
order_number: 'WO-002',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-11-06T08:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-10T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
order_number: 'WO-003',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-11-11T08:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-15T17:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SubsidiaryData = [
|
|
{
|
|
name: 'Ernst Mayr',
|
|
},
|
|
|
|
{
|
|
name: 'Edward O. Wilson',
|
|
},
|
|
|
|
{
|
|
name: 'Alfred Wegener',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setSubsidiary) {
|
|
await User0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setSubsidiary) {
|
|
await User1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setSubsidiary) {
|
|
await User2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateHumanResourceWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const HumanResource0 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (HumanResource0?.setSubsidiary) {
|
|
await HumanResource0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const HumanResource1 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (HumanResource1?.setSubsidiary) {
|
|
await HumanResource1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const HumanResource2 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (HumanResource2?.setSubsidiary) {
|
|
await HumanResource2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateInventoryWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Inventory0 = await Inventory.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Inventory0?.setSubsidiary) {
|
|
await Inventory0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Inventory1 = await Inventory.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Inventory1?.setSubsidiary) {
|
|
await Inventory1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Inventory2 = await Inventory.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Inventory2?.setSubsidiary) {
|
|
await Inventory2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateMachineryWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Machinery0 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Machinery0?.setSubsidiary) {
|
|
await Machinery0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Machinery1 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Machinery1?.setSubsidiary) {
|
|
await Machinery1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Machinery2 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Machinery2?.setSubsidiary) {
|
|
await Machinery2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateQualityControlWithWork_order() {
|
|
const relatedWork_order0 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QualityControl0 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (QualityControl0?.setWork_order) {
|
|
await QualityControl0.setWork_order(relatedWork_order0);
|
|
}
|
|
|
|
const relatedWork_order1 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QualityControl1 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (QualityControl1?.setWork_order) {
|
|
await QualityControl1.setWork_order(relatedWork_order1);
|
|
}
|
|
|
|
const relatedWork_order2 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QualityControl2 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (QualityControl2?.setWork_order) {
|
|
await QualityControl2.setWork_order(relatedWork_order2);
|
|
}
|
|
}
|
|
|
|
async function associateQualityControlWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const QualityControl0 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (QualityControl0?.setSubsidiary) {
|
|
await QualityControl0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const QualityControl1 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (QualityControl1?.setSubsidiary) {
|
|
await QualityControl1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const QualityControl2 = await QualityControl.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (QualityControl2?.setSubsidiary) {
|
|
await QualityControl2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateRawMaterialWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const RawMaterial0 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (RawMaterial0?.setSubsidiary) {
|
|
await RawMaterial0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const RawMaterial1 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (RawMaterial1?.setSubsidiary) {
|
|
await RawMaterial1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const RawMaterial2 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (RawMaterial2?.setSubsidiary) {
|
|
await RawMaterial2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
async function associateSubsidiaryWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Subsidiary0 = await Subsidiaries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Subsidiary0?.setSubsidiary) {
|
|
await Subsidiary0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Subsidiary1 = await Subsidiaries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Subsidiary1?.setSubsidiary) {
|
|
await Subsidiary1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Subsidiary2 = await Subsidiaries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Subsidiary2?.setSubsidiary) {
|
|
await Subsidiary2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateSupplierWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Supplier0 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Supplier0?.setSubsidiary) {
|
|
await Supplier0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Supplier1 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Supplier1?.setSubsidiary) {
|
|
await Supplier1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const Supplier2 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Supplier2?.setSubsidiary) {
|
|
await Supplier2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateWorkOrderWithAssigned_to() {
|
|
const relatedAssigned_to0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setAssigned_to) {
|
|
await WorkOrder0.setAssigned_to(relatedAssigned_to0);
|
|
}
|
|
|
|
const relatedAssigned_to1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setAssigned_to) {
|
|
await WorkOrder1.setAssigned_to(relatedAssigned_to1);
|
|
}
|
|
|
|
const relatedAssigned_to2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setAssigned_to) {
|
|
await WorkOrder2.setAssigned_to(relatedAssigned_to2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithSubsidiary() {
|
|
const relatedSubsidiary0 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setSubsidiary) {
|
|
await WorkOrder0.setSubsidiary(relatedSubsidiary0);
|
|
}
|
|
|
|
const relatedSubsidiary1 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setSubsidiary) {
|
|
await WorkOrder1.setSubsidiary(relatedSubsidiary1);
|
|
}
|
|
|
|
const relatedSubsidiary2 = await Subsidiary.findOne({
|
|
offset: Math.floor(Math.random() * (await Subsidiary.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setSubsidiary) {
|
|
await WorkOrder2.setSubsidiary(relatedSubsidiary2);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await HumanResources.bulkCreate(HumanResourcesData);
|
|
|
|
await Inventory.bulkCreate(InventoryData);
|
|
|
|
await Machinery.bulkCreate(MachineryData);
|
|
|
|
await QualityControl.bulkCreate(QualityControlData);
|
|
|
|
await RawMaterials.bulkCreate(RawMaterialsData);
|
|
|
|
await Subsidiaries.bulkCreate(SubsidiariesData);
|
|
|
|
await Suppliers.bulkCreate(SuppliersData);
|
|
|
|
await WorkOrders.bulkCreate(WorkOrdersData);
|
|
|
|
await Subsidiary.bulkCreate(SubsidiaryData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithSubsidiary(),
|
|
|
|
await associateHumanResourceWithSubsidiary(),
|
|
|
|
await associateInventoryWithSubsidiary(),
|
|
|
|
await associateMachineryWithSubsidiary(),
|
|
|
|
await associateQualityControlWithWork_order(),
|
|
|
|
await associateQualityControlWithSubsidiary(),
|
|
|
|
await associateRawMaterialWithSubsidiary(),
|
|
|
|
await associateSubsidiaryWithSubsidiary(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateSupplierWithSubsidiary(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateWorkOrderWithAssigned_to(),
|
|
|
|
await associateWorkOrderWithSubsidiary(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('human_resources', null, {});
|
|
|
|
await queryInterface.bulkDelete('inventory', null, {});
|
|
|
|
await queryInterface.bulkDelete('machinery', null, {});
|
|
|
|
await queryInterface.bulkDelete('quality_control', null, {});
|
|
|
|
await queryInterface.bulkDelete('raw_materials', null, {});
|
|
|
|
await queryInterface.bulkDelete('subsidiaries', null, {});
|
|
|
|
await queryInterface.bulkDelete('suppliers', null, {});
|
|
|
|
await queryInterface.bulkDelete('work_orders', null, {});
|
|
|
|
await queryInterface.bulkDelete('subsidiary', null, {});
|
|
},
|
|
};
|