30883/backend/src/db/seeders/20231127130745-sample-data.js
2025-04-21 07:29:21 +00:00

1163 lines
27 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Alerts = db.alerts;
const Expenses = db.expenses;
const Financials = db.financials;
const Sales = db.sales;
const Stations = db.stations;
const Stocks = db.stocks;
const Tanks = db.tanks;
const Organizations = db.organizations;
const AlertsData = [
{
// type code here for "relation_one" field
alert_type: 'Stock Low',
description: 'Diesel stock below threshold',
date_triggered: new Date('2023-10-01T08:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
alert_type: 'Maintenance Required',
description: 'Pump 3 requires servicing',
date_triggered: new Date('2023-10-01T09:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
alert_type: 'Stock Discrepancy',
description: 'Kerosene stock mismatch detected',
date_triggered: new Date('2023-10-01T10:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
alert_type: 'High Expenditure',
description: 'Salaries exceed budget',
date_triggered: new Date('2023-10-01T11:00:00Z'),
// type code here for "relation_one" field
},
];
const ExpensesData = [
{
// type code here for "relation_one" field
category: 'Fuel',
amount: 1000,
date_incurred: new Date('2023-10-01T08:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
category: 'Maintenance',
amount: 500,
date_incurred: new Date('2023-10-01T09:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
category: 'Utilities',
amount: 300,
date_incurred: new Date('2023-10-01T10:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
category: 'Salaries',
amount: 2000,
date_incurred: new Date('2023-10-01T11:00:00Z'),
// type code here for "relation_one" field
},
];
const FinancialsData = [
{
// type code here for "relation_one" field
total_credits: 5000,
total_debts: 2000,
last_reviewed: new Date('2023-10-01T08:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
total_credits: 6000,
total_debts: 2500,
last_reviewed: new Date('2023-10-01T09:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
total_credits: 4000,
total_debts: 1500,
last_reviewed: new Date('2023-10-01T10:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
total_credits: 7000,
total_debts: 3000,
last_reviewed: new Date('2023-10-01T11:00:00Z'),
// type code here for "relation_one" field
},
];
const SalesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
sale_date: new Date('2023-10-01T08:00:00Z'),
quantity_sold: 150.5,
total_amount: 300.75,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
sale_date: new Date('2023-10-01T09:00:00Z'),
quantity_sold: 200,
total_amount: 400,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
sale_date: new Date('2023-10-01T10:00:00Z'),
quantity_sold: 175.25,
total_amount: 350.5,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
sale_date: new Date('2023-10-01T11:00:00Z'),
quantity_sold: 160,
total_amount: 320,
// type code here for "relation_one" field
},
];
const StationsData = [
{
name: 'Station A',
location: 'Downtown',
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
name: 'Station B',
location: 'Uptown',
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
name: 'Station C',
location: 'Suburb',
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
name: 'Station D',
location: 'Industrial Area',
// type code here for "relation_many" field
// type code here for "relation_one" field
},
];
const StocksData = [
{
// type code here for "relation_one" field
product: 'Diesel',
initial_stock: 1000,
current_stock: 850.5,
last_updated: new Date('2023-10-01T08:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Petrol',
initial_stock: 1200,
current_stock: 1000,
last_updated: new Date('2023-10-01T09:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Kerosene',
initial_stock: 800,
current_stock: 625.25,
last_updated: new Date('2023-10-01T10:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Lubricants',
initial_stock: 500,
current_stock: 340,
last_updated: new Date('2023-10-01T11:00:00Z'),
// type code here for "relation_one" field
},
];
const TanksData = [
{
// type code here for "relation_one" field
product: 'Diesel',
capacity: 2000,
current_level: 850.5,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Petrol',
capacity: 2500,
current_level: 1000,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Kerosene',
capacity: 1500,
current_level: 625.25,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
product: 'Lubricants',
capacity: 1000,
current_level: 340,
// type code here for "relation_one" field
},
];
const OrganizationsData = [
{
name: 'Hans Selye',
},
{
name: 'Albert Einstein',
},
{
name: 'Franz Boas',
},
{
name: 'Sigmund Freud',
},
];
// 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);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (User3?.setOrganization) {
await User3.setOrganization(relatedOrganization3);
}
}
async function associateAlertWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Alert0 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Alert0?.setStation) {
await Alert0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Alert1 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Alert1?.setStation) {
await Alert1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Alert2 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Alert2?.setStation) {
await Alert2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Alert3 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Alert3?.setStation) {
await Alert3.setStation(relatedStation3);
}
}
async function associateAlertWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Alert0 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Alert0?.setOrganization) {
await Alert0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Alert1 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Alert1?.setOrganization) {
await Alert1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Alert2 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Alert2?.setOrganization) {
await Alert2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Alert3 = await Alerts.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Alert3?.setOrganization) {
await Alert3.setOrganization(relatedOrganization3);
}
}
async function associateExpenseWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Expense0 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Expense0?.setStation) {
await Expense0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Expense1 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Expense1?.setStation) {
await Expense1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Expense2 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Expense2?.setStation) {
await Expense2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Expense3 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Expense3?.setStation) {
await Expense3.setStation(relatedStation3);
}
}
async function associateExpenseWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Expense0 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Expense0?.setOrganization) {
await Expense0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Expense1 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Expense1?.setOrganization) {
await Expense1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Expense2 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Expense2?.setOrganization) {
await Expense2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Expense3 = await Expenses.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Expense3?.setOrganization) {
await Expense3.setOrganization(relatedOrganization3);
}
}
async function associateFinancialWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Financial0 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Financial0?.setStation) {
await Financial0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Financial1 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Financial1?.setStation) {
await Financial1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Financial2 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Financial2?.setStation) {
await Financial2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Financial3 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Financial3?.setStation) {
await Financial3.setStation(relatedStation3);
}
}
async function associateFinancialWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Financial0 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Financial0?.setOrganization) {
await Financial0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Financial1 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Financial1?.setOrganization) {
await Financial1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Financial2 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Financial2?.setOrganization) {
await Financial2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Financial3 = await Financials.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Financial3?.setOrganization) {
await Financial3.setOrganization(relatedOrganization3);
}
}
async function associateSaleWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Sale0 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Sale0?.setStation) {
await Sale0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Sale1 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Sale1?.setStation) {
await Sale1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Sale2 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Sale2?.setStation) {
await Sale2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Sale3 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Sale3?.setStation) {
await Sale3.setStation(relatedStation3);
}
}
async function associateSaleWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Sale0 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Sale0?.setUser) {
await Sale0.setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Sale1 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Sale1?.setUser) {
await Sale1.setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Sale2 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Sale2?.setUser) {
await Sale2.setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Sale3 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Sale3?.setUser) {
await Sale3.setUser(relatedUser3);
}
}
async function associateSaleWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sale0 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Sale0?.setOrganization) {
await Sale0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sale1 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Sale1?.setOrganization) {
await Sale1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sale2 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Sale2?.setOrganization) {
await Sale2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sale3 = await Sales.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Sale3?.setOrganization) {
await Sale3.setOrganization(relatedOrganization3);
}
}
// Similar logic for "relation_many"
async function associateStationWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Station0 = await Stations.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Station0?.setOrganization) {
await Station0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Station1 = await Stations.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Station1?.setOrganization) {
await Station1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Station2 = await Stations.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Station2?.setOrganization) {
await Station2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Station3 = await Stations.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Station3?.setOrganization) {
await Station3.setOrganization(relatedOrganization3);
}
}
async function associateStockWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Stock0 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Stock0?.setStation) {
await Stock0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Stock1 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Stock1?.setStation) {
await Stock1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Stock2 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Stock2?.setStation) {
await Stock2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Stock3 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Stock3?.setStation) {
await Stock3.setStation(relatedStation3);
}
}
async function associateStockWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Stock0 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Stock0?.setOrganization) {
await Stock0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Stock1 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Stock1?.setOrganization) {
await Stock1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Stock2 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Stock2?.setOrganization) {
await Stock2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Stock3 = await Stocks.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Stock3?.setOrganization) {
await Stock3.setOrganization(relatedOrganization3);
}
}
async function associateTankWithStation() {
const relatedStation0 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Tank0 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Tank0?.setStation) {
await Tank0.setStation(relatedStation0);
}
const relatedStation1 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Tank1 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Tank1?.setStation) {
await Tank1.setStation(relatedStation1);
}
const relatedStation2 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Tank2 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Tank2?.setStation) {
await Tank2.setStation(relatedStation2);
}
const relatedStation3 = await Stations.findOne({
offset: Math.floor(Math.random() * (await Stations.count())),
});
const Tank3 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Tank3?.setStation) {
await Tank3.setStation(relatedStation3);
}
}
async function associateTankWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Tank0 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Tank0?.setOrganization) {
await Tank0.setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Tank1 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Tank1?.setOrganization) {
await Tank1.setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Tank2 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Tank2?.setOrganization) {
await Tank2.setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Tank3 = await Tanks.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Tank3?.setOrganization) {
await Tank3.setOrganization(relatedOrganization3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Alerts.bulkCreate(AlertsData);
await Expenses.bulkCreate(ExpensesData);
await Financials.bulkCreate(FinancialsData);
await Sales.bulkCreate(SalesData);
await Stations.bulkCreate(StationsData);
await Stocks.bulkCreate(StocksData);
await Tanks.bulkCreate(TanksData);
await Organizations.bulkCreate(OrganizationsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithOrganization(),
await associateAlertWithStation(),
await associateAlertWithOrganization(),
await associateExpenseWithStation(),
await associateExpenseWithOrganization(),
await associateFinancialWithStation(),
await associateFinancialWithOrganization(),
await associateSaleWithStation(),
await associateSaleWithUser(),
await associateSaleWithOrganization(),
// Similar logic for "relation_many"
await associateStationWithOrganization(),
await associateStockWithStation(),
await associateStockWithOrganization(),
await associateTankWithStation(),
await associateTankWithOrganization(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('alerts', null, {});
await queryInterface.bulkDelete('expenses', null, {});
await queryInterface.bulkDelete('financials', null, {});
await queryInterface.bulkDelete('sales', null, {});
await queryInterface.bulkDelete('stations', null, {});
await queryInterface.bulkDelete('stocks', null, {});
await queryInterface.bulkDelete('tanks', null, {});
await queryInterface.bulkDelete('organizations', null, {});
},
};