810 lines
20 KiB
JavaScript
810 lines
20 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const HumanResources = db.human_resources;
|
|
|
|
const Inventories = db.inventories;
|
|
|
|
const Machinery = db.machinery;
|
|
|
|
const QualityControls = db.quality_controls;
|
|
|
|
const RawMaterials = db.raw_materials;
|
|
|
|
const Suppliers = db.suppliers;
|
|
|
|
const WorkOrders = db.work_orders;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const HumanResourcesData = [
|
|
{
|
|
employee_name: 'Alice Green',
|
|
|
|
role: 'Production Manager',
|
|
|
|
payroll: 75000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
employee_name: 'Bob White',
|
|
|
|
role: 'Inventory Manager',
|
|
|
|
payroll: 65000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
employee_name: 'Charlie Black',
|
|
|
|
role: 'Quality Controller',
|
|
|
|
payroll: 60000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const InventoriesData = [
|
|
{
|
|
product_name: 'Steel Beams',
|
|
|
|
available_quantity: 200,
|
|
|
|
reserved_quantity: 50,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
product_name: 'Aluminum Sheets',
|
|
|
|
available_quantity: 150,
|
|
|
|
reserved_quantity: 30,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
product_name: 'Copper Coils',
|
|
|
|
available_quantity: 100,
|
|
|
|
reserved_quantity: 20,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const MachineryData = [
|
|
{
|
|
name: 'CNC Machine',
|
|
|
|
maintenance_schedule: new Date('2023-11-01T10:00:00Z'),
|
|
|
|
status: 'Operational',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Lathe Machine',
|
|
|
|
maintenance_schedule: new Date('2023-11-05T14:00:00Z'),
|
|
|
|
status: 'Under Maintenance',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Wire Cutter',
|
|
|
|
maintenance_schedule: new Date('2023-11-10T09:00:00Z'),
|
|
|
|
status: 'Operational',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const QualityControlsData = [
|
|
{
|
|
check_name: 'Initial Check',
|
|
|
|
check_date: new Date('2023-10-01T08:00:00Z'),
|
|
|
|
passed: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
check_name: 'Final Inspection',
|
|
|
|
check_date: new Date('2023-10-02T09:00:00Z'),
|
|
|
|
passed: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
check_name: 'Quality Assurance',
|
|
|
|
check_date: new Date('2023-10-03T10:00:00Z'),
|
|
|
|
passed: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const RawMaterialsData = [
|
|
{
|
|
name: 'Steel Sheets',
|
|
|
|
quantity: 1000,
|
|
|
|
reorder_level: 200,
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Aluminum Rods',
|
|
|
|
quantity: 500,
|
|
|
|
reorder_level: 100,
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Copper Wires',
|
|
|
|
quantity: 300,
|
|
|
|
reorder_level: 50,
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SuppliersData = [
|
|
{
|
|
company_name: 'Metal Supplies Inc.',
|
|
|
|
contact_person: 'John Doe',
|
|
|
|
contract_terms: 'Annual contract with quarterly reviews.',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Plastics Co.',
|
|
|
|
contact_person: 'Jane Smith',
|
|
|
|
contract_terms: 'Bi-annual contract with monthly deliveries.',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
company_name: 'Glassworks Ltd.',
|
|
|
|
contact_person: 'Emily Johnson',
|
|
|
|
contract_terms: 'Monthly contract with weekly deliveries.',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const WorkOrdersData = [
|
|
{
|
|
order_number: 'WO-001',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
order_number: 'WO-002',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
order_number: 'WO-003',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Louis Pasteur',
|
|
},
|
|
|
|
{
|
|
name: 'Antoine Laurent Lavoisier',
|
|
},
|
|
|
|
{
|
|
name: 'Charles Sherrington',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setOrganization) {
|
|
await User0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setOrganization) {
|
|
await User1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setOrganization) {
|
|
await User2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateHumanResourceWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HumanResource0 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (HumanResource0?.setOrganization) {
|
|
await HumanResource0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HumanResource1 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (HumanResource1?.setOrganization) {
|
|
await HumanResource1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const HumanResource2 = await HumanResources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (HumanResource2?.setOrganization) {
|
|
await HumanResource2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateInventoryWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Inventory0 = await Inventories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Inventory0?.setOrganization) {
|
|
await Inventory0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Inventory1 = await Inventories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Inventory1?.setOrganization) {
|
|
await Inventory1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Inventory2 = await Inventories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Inventory2?.setOrganization) {
|
|
await Inventory2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateMachineryWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Machinery0 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Machinery0?.setOrganization) {
|
|
await Machinery0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Machinery1 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Machinery1?.setOrganization) {
|
|
await Machinery1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Machinery2 = await Machinery.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Machinery2?.setOrganization) {
|
|
await Machinery2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateQualityControlWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QualityControl0 = await QualityControls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (QualityControl0?.setOrganization) {
|
|
await QualityControl0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QualityControl1 = await QualityControls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (QualityControl1?.setOrganization) {
|
|
await QualityControl1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QualityControl2 = await QualityControls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (QualityControl2?.setOrganization) {
|
|
await QualityControl2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateRawMaterialWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const RawMaterial0 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (RawMaterial0?.setOrganization) {
|
|
await RawMaterial0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const RawMaterial1 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (RawMaterial1?.setOrganization) {
|
|
await RawMaterial1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const RawMaterial2 = await RawMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (RawMaterial2?.setOrganization) {
|
|
await RawMaterial2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateSupplierWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Supplier0 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Supplier0?.setOrganization) {
|
|
await Supplier0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Supplier1 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Supplier1?.setOrganization) {
|
|
await Supplier1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Supplier2 = await Suppliers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Supplier2?.setOrganization) {
|
|
await Supplier2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithRaw_material() {
|
|
const relatedRaw_material0 = await RawMaterials.findOne({
|
|
offset: Math.floor(Math.random() * (await RawMaterials.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setRaw_material) {
|
|
await WorkOrder0.setRaw_material(relatedRaw_material0);
|
|
}
|
|
|
|
const relatedRaw_material1 = await RawMaterials.findOne({
|
|
offset: Math.floor(Math.random() * (await RawMaterials.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setRaw_material) {
|
|
await WorkOrder1.setRaw_material(relatedRaw_material1);
|
|
}
|
|
|
|
const relatedRaw_material2 = await RawMaterials.findOne({
|
|
offset: Math.floor(Math.random() * (await RawMaterials.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setRaw_material) {
|
|
await WorkOrder2.setRaw_material(relatedRaw_material2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithMachinery() {
|
|
const relatedMachinery0 = await Machinery.findOne({
|
|
offset: Math.floor(Math.random() * (await Machinery.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setMachinery) {
|
|
await WorkOrder0.setMachinery(relatedMachinery0);
|
|
}
|
|
|
|
const relatedMachinery1 = await Machinery.findOne({
|
|
offset: Math.floor(Math.random() * (await Machinery.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setMachinery) {
|
|
await WorkOrder1.setMachinery(relatedMachinery1);
|
|
}
|
|
|
|
const relatedMachinery2 = await Machinery.findOne({
|
|
offset: Math.floor(Math.random() * (await Machinery.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setMachinery) {
|
|
await WorkOrder2.setMachinery(relatedMachinery2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithQuality_control() {
|
|
const relatedQuality_control0 = await QualityControls.findOne({
|
|
offset: Math.floor(Math.random() * (await QualityControls.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setQuality_control) {
|
|
await WorkOrder0.setQuality_control(relatedQuality_control0);
|
|
}
|
|
|
|
const relatedQuality_control1 = await QualityControls.findOne({
|
|
offset: Math.floor(Math.random() * (await QualityControls.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setQuality_control) {
|
|
await WorkOrder1.setQuality_control(relatedQuality_control1);
|
|
}
|
|
|
|
const relatedQuality_control2 = await QualityControls.findOne({
|
|
offset: Math.floor(Math.random() * (await QualityControls.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setQuality_control) {
|
|
await WorkOrder2.setQuality_control(relatedQuality_control2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithInventory() {
|
|
const relatedInventory0 = await Inventories.findOne({
|
|
offset: Math.floor(Math.random() * (await Inventories.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setInventory) {
|
|
await WorkOrder0.setInventory(relatedInventory0);
|
|
}
|
|
|
|
const relatedInventory1 = await Inventories.findOne({
|
|
offset: Math.floor(Math.random() * (await Inventories.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setInventory) {
|
|
await WorkOrder1.setInventory(relatedInventory1);
|
|
}
|
|
|
|
const relatedInventory2 = await Inventories.findOne({
|
|
offset: Math.floor(Math.random() * (await Inventories.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setInventory) {
|
|
await WorkOrder2.setInventory(relatedInventory2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setUser) {
|
|
await WorkOrder0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setUser) {
|
|
await WorkOrder1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setUser) {
|
|
await WorkOrder2.setUser(relatedUser2);
|
|
}
|
|
}
|
|
|
|
async function associateWorkOrderWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (WorkOrder0?.setOrganization) {
|
|
await WorkOrder0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (WorkOrder1?.setOrganization) {
|
|
await WorkOrder1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (WorkOrder2?.setOrganization) {
|
|
await WorkOrder2.setOrganization(relatedOrganization2);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await HumanResources.bulkCreate(HumanResourcesData);
|
|
|
|
await Inventories.bulkCreate(InventoriesData);
|
|
|
|
await Machinery.bulkCreate(MachineryData);
|
|
|
|
await QualityControls.bulkCreate(QualityControlsData);
|
|
|
|
await RawMaterials.bulkCreate(RawMaterialsData);
|
|
|
|
await Suppliers.bulkCreate(SuppliersData);
|
|
|
|
await WorkOrders.bulkCreate(WorkOrdersData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateHumanResourceWithOrganization(),
|
|
|
|
await associateInventoryWithOrganization(),
|
|
|
|
await associateMachineryWithOrganization(),
|
|
|
|
await associateQualityControlWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateRawMaterialWithOrganization(),
|
|
|
|
await associateSupplierWithOrganization(),
|
|
|
|
await associateWorkOrderWithRaw_material(),
|
|
|
|
await associateWorkOrderWithMachinery(),
|
|
|
|
await associateWorkOrderWithQuality_control(),
|
|
|
|
await associateWorkOrderWithInventory(),
|
|
|
|
await associateWorkOrderWithUser(),
|
|
|
|
await associateWorkOrderWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('human_resources', null, {});
|
|
|
|
await queryInterface.bulkDelete('inventories', null, {});
|
|
|
|
await queryInterface.bulkDelete('machinery', null, {});
|
|
|
|
await queryInterface.bulkDelete('quality_controls', null, {});
|
|
|
|
await queryInterface.bulkDelete('raw_materials', null, {});
|
|
|
|
await queryInterface.bulkDelete('suppliers', null, {});
|
|
|
|
await queryInterface.bulkDelete('work_orders', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|