788 lines
19 KiB
JavaScript
788 lines
19 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Prompts = db.prompts;
|
|
|
|
const Sales = db.sales;
|
|
|
|
const Transactions = db.transactions;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const PromptsData = [
|
|
{
|
|
title: 'AI Chatbot Script',
|
|
|
|
description: 'A comprehensive script for AI chatbots.',
|
|
|
|
price: 200,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
category: 'Health',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Business Strategy Template',
|
|
|
|
description: 'A template for creating business strategies.',
|
|
|
|
price: 150,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
category: 'Education',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Educational AI Prompt',
|
|
|
|
description: 'AI prompts for educational purposes.',
|
|
|
|
price: 100,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
category: 'Health',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Health Monitoring AI',
|
|
|
|
description: 'AI prompts for health monitoring applications.',
|
|
|
|
price: 250,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
category: 'Business',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'AI Marketing Guide',
|
|
|
|
description: 'A guide for AI-driven marketing strategies.',
|
|
|
|
price: 180,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
category: 'Business',
|
|
|
|
// 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-01T10:00:00Z'),
|
|
|
|
points_earned: 200,
|
|
|
|
// 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-02T11:30:00Z'),
|
|
|
|
points_earned: 150,
|
|
|
|
// 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-03T14:00:00Z'),
|
|
|
|
points_earned: 100,
|
|
|
|
// 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-04T09:00:00Z'),
|
|
|
|
points_earned: 250,
|
|
|
|
// 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-05T16:00:00Z'),
|
|
|
|
points_earned: 180,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const TransactionsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
transaction_date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
status: 'Completed',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
transaction_date: new Date('2023-10-02T11:30:00Z'),
|
|
|
|
status: 'Failed',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
transaction_date: new Date('2023-10-03T14:00:00Z'),
|
|
|
|
status: 'Pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
transaction_date: new Date('2023-10-04T09:00:00Z'),
|
|
|
|
status: 'Failed',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
transaction_date: new Date('2023-10-05T16:00:00Z'),
|
|
|
|
status: 'Pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Tech Innovators',
|
|
},
|
|
|
|
{
|
|
name: 'AI Pioneers',
|
|
},
|
|
|
|
{
|
|
name: 'Future Creators',
|
|
},
|
|
|
|
{
|
|
name: 'Prompt Masters',
|
|
},
|
|
|
|
{
|
|
name: 'Digital Thinkers',
|
|
},
|
|
];
|
|
|
|
// 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);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setOrganization) {
|
|
await User4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePromptWithSeller() {
|
|
const relatedSeller0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Prompt0 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Prompt0?.setSeller) {
|
|
await Prompt0.setSeller(relatedSeller0);
|
|
}
|
|
|
|
const relatedSeller1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Prompt1 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Prompt1?.setSeller) {
|
|
await Prompt1.setSeller(relatedSeller1);
|
|
}
|
|
|
|
const relatedSeller2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Prompt2 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Prompt2?.setSeller) {
|
|
await Prompt2.setSeller(relatedSeller2);
|
|
}
|
|
|
|
const relatedSeller3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Prompt3 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Prompt3?.setSeller) {
|
|
await Prompt3.setSeller(relatedSeller3);
|
|
}
|
|
|
|
const relatedSeller4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Prompt4 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Prompt4?.setSeller) {
|
|
await Prompt4.setSeller(relatedSeller4);
|
|
}
|
|
}
|
|
|
|
async function associatePromptWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Prompt0 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Prompt0?.setOrganization) {
|
|
await Prompt0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Prompt1 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Prompt1?.setOrganization) {
|
|
await Prompt1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Prompt2 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Prompt2?.setOrganization) {
|
|
await Prompt2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Prompt3 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Prompt3?.setOrganization) {
|
|
await Prompt3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Prompt4 = await Prompts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Prompt4?.setOrganization) {
|
|
await Prompt4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateSaleWithSeller() {
|
|
const relatedSeller0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Sale0 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Sale0?.setSeller) {
|
|
await Sale0.setSeller(relatedSeller0);
|
|
}
|
|
|
|
const relatedSeller1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Sale1 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Sale1?.setSeller) {
|
|
await Sale1.setSeller(relatedSeller1);
|
|
}
|
|
|
|
const relatedSeller2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Sale2 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Sale2?.setSeller) {
|
|
await Sale2.setSeller(relatedSeller2);
|
|
}
|
|
|
|
const relatedSeller3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Sale3 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Sale3?.setSeller) {
|
|
await Sale3.setSeller(relatedSeller3);
|
|
}
|
|
|
|
const relatedSeller4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Sale4 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Sale4?.setSeller) {
|
|
await Sale4.setSeller(relatedSeller4);
|
|
}
|
|
}
|
|
|
|
async function associateSaleWithPrompt() {
|
|
const relatedPrompt0 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Sale0 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Sale0?.setPrompt) {
|
|
await Sale0.setPrompt(relatedPrompt0);
|
|
}
|
|
|
|
const relatedPrompt1 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Sale1 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Sale1?.setPrompt) {
|
|
await Sale1.setPrompt(relatedPrompt1);
|
|
}
|
|
|
|
const relatedPrompt2 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Sale2 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Sale2?.setPrompt) {
|
|
await Sale2.setPrompt(relatedPrompt2);
|
|
}
|
|
|
|
const relatedPrompt3 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Sale3 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Sale3?.setPrompt) {
|
|
await Sale3.setPrompt(relatedPrompt3);
|
|
}
|
|
|
|
const relatedPrompt4 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Sale4 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Sale4?.setPrompt) {
|
|
await Sale4.setPrompt(relatedPrompt4);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Sale4 = await Sales.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Sale4?.setOrganization) {
|
|
await Sale4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateTransactionWithBuyer() {
|
|
const relatedBuyer0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Transaction0 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Transaction0?.setBuyer) {
|
|
await Transaction0.setBuyer(relatedBuyer0);
|
|
}
|
|
|
|
const relatedBuyer1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Transaction1 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Transaction1?.setBuyer) {
|
|
await Transaction1.setBuyer(relatedBuyer1);
|
|
}
|
|
|
|
const relatedBuyer2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Transaction2 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Transaction2?.setBuyer) {
|
|
await Transaction2.setBuyer(relatedBuyer2);
|
|
}
|
|
|
|
const relatedBuyer3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Transaction3 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Transaction3?.setBuyer) {
|
|
await Transaction3.setBuyer(relatedBuyer3);
|
|
}
|
|
|
|
const relatedBuyer4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Transaction4 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Transaction4?.setBuyer) {
|
|
await Transaction4.setBuyer(relatedBuyer4);
|
|
}
|
|
}
|
|
|
|
async function associateTransactionWithPrompt() {
|
|
const relatedPrompt0 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Transaction0 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Transaction0?.setPrompt) {
|
|
await Transaction0.setPrompt(relatedPrompt0);
|
|
}
|
|
|
|
const relatedPrompt1 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Transaction1 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Transaction1?.setPrompt) {
|
|
await Transaction1.setPrompt(relatedPrompt1);
|
|
}
|
|
|
|
const relatedPrompt2 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Transaction2 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Transaction2?.setPrompt) {
|
|
await Transaction2.setPrompt(relatedPrompt2);
|
|
}
|
|
|
|
const relatedPrompt3 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Transaction3 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Transaction3?.setPrompt) {
|
|
await Transaction3.setPrompt(relatedPrompt3);
|
|
}
|
|
|
|
const relatedPrompt4 = await Prompts.findOne({
|
|
offset: Math.floor(Math.random() * (await Prompts.count())),
|
|
});
|
|
const Transaction4 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Transaction4?.setPrompt) {
|
|
await Transaction4.setPrompt(relatedPrompt4);
|
|
}
|
|
}
|
|
|
|
async function associateTransactionWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Transaction0 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Transaction0?.setOrganization) {
|
|
await Transaction0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Transaction1 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Transaction1?.setOrganization) {
|
|
await Transaction1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Transaction2 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Transaction2?.setOrganization) {
|
|
await Transaction2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Transaction3 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Transaction3?.setOrganization) {
|
|
await Transaction3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Transaction4 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Transaction4?.setOrganization) {
|
|
await Transaction4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Prompts.bulkCreate(PromptsData);
|
|
|
|
await Sales.bulkCreate(SalesData);
|
|
|
|
await Transactions.bulkCreate(TransactionsData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associatePromptWithSeller(),
|
|
|
|
await associatePromptWithOrganization(),
|
|
|
|
await associateSaleWithSeller(),
|
|
|
|
await associateSaleWithPrompt(),
|
|
|
|
await associateSaleWithOrganization(),
|
|
|
|
await associateTransactionWithBuyer(),
|
|
|
|
await associateTransactionWithPrompt(),
|
|
|
|
await associateTransactionWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('prompts', null, {});
|
|
|
|
await queryInterface.bulkDelete('sales', null, {});
|
|
|
|
await queryInterface.bulkDelete('transactions', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|