1012 lines
24 KiB
JavaScript
1012 lines
24 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Analytics = db.analytics;
|
|
|
|
const Domains = db.domains;
|
|
|
|
const Payments = db.payments;
|
|
|
|
const Sites = db.sites;
|
|
|
|
const SupportTickets = db.support_tickets;
|
|
|
|
const Workspaces = db.workspaces;
|
|
|
|
const AnalyticsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
visitors: 1500,
|
|
|
|
date: new Date('2023-10-01T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
visitors: 1200,
|
|
|
|
date: new Date('2023-10-05T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
visitors: 800,
|
|
|
|
date: new Date('2023-10-10T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
visitors: 2000,
|
|
|
|
date: new Date('2023-10-15T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
visitors: 500,
|
|
|
|
date: new Date('2023-10-20T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const DomainsData = [
|
|
{
|
|
domain_name: 'acme-corp.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
is_ssl_enabled: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
domain_name: 'tech-innovators.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
is_ssl_enabled: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
domain_name: 'creative-solutions.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
is_ssl_enabled: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
domain_name: 'global-enterprises.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
is_ssl_enabled: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
domain_name: 'startup-hub.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
is_ssl_enabled: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PaymentsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
payment_method: 'paypal',
|
|
|
|
amount: 99.99,
|
|
|
|
payment_date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
payment_method: 'paystack',
|
|
|
|
amount: 49.99,
|
|
|
|
payment_date: new Date('2023-10-05T12:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
payment_method: 'paypal',
|
|
|
|
amount: 29.99,
|
|
|
|
payment_date: new Date('2023-10-10T14:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
payment_method: 'paystack',
|
|
|
|
amount: 199.99,
|
|
|
|
payment_date: new Date('2023-10-15T16:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
payment_method: 'paystack',
|
|
|
|
amount: 9.99,
|
|
|
|
payment_date: new Date('2023-10-20T18:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SitesData = [
|
|
{
|
|
title: 'Acme Marketing Site',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
published_at: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
is_active: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Tech Innovators Blog',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
published_at: new Date('2023-10-05T12:00:00Z'),
|
|
|
|
is_active: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Creative Solutions Portfolio',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
published_at: new Date('2023-10-10T14:00:00Z'),
|
|
|
|
is_active: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Global Enterprises E-commerce',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
published_at: new Date('2023-10-15T16:00:00Z'),
|
|
|
|
is_active: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Startup Hub Landing Page',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
published_at: new Date('2023-10-20T18:00:00Z'),
|
|
|
|
is_active: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const SupportTicketsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
subject: 'Site not loading',
|
|
|
|
description: 'The site is not loading after publishing.',
|
|
|
|
status: 'pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
subject: 'Payment issue',
|
|
|
|
description: 'Payment failed during checkout.',
|
|
|
|
status: 'closed',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
subject: 'Domain setup',
|
|
|
|
description: 'Need help setting up the domain.',
|
|
|
|
status: 'open',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
subject: 'SSL certificate error',
|
|
|
|
description: 'SSL certificate is not valid.',
|
|
|
|
status: 'open',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
subject: 'Analytics not updating',
|
|
|
|
description: 'Visitor analytics are not updating.',
|
|
|
|
status: 'open',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const WorkspacesData = [
|
|
{
|
|
name: 'Acme Corp',
|
|
},
|
|
|
|
{
|
|
name: 'Tech Innovators',
|
|
},
|
|
|
|
{
|
|
name: 'Creative Solutions',
|
|
},
|
|
|
|
{
|
|
name: 'Global Enterprises',
|
|
},
|
|
|
|
{
|
|
name: 'Startup Hub',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setWorkspace) {
|
|
await User0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setWorkspace) {
|
|
await User1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setWorkspace) {
|
|
await User2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setWorkspace) {
|
|
await User3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setWorkspace) {
|
|
await User4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateAnalyticWithSite() {
|
|
const relatedSite0 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Analytic0 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Analytic0?.setSite) {
|
|
await Analytic0.setSite(relatedSite0);
|
|
}
|
|
|
|
const relatedSite1 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Analytic1 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Analytic1?.setSite) {
|
|
await Analytic1.setSite(relatedSite1);
|
|
}
|
|
|
|
const relatedSite2 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Analytic2 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Analytic2?.setSite) {
|
|
await Analytic2.setSite(relatedSite2);
|
|
}
|
|
|
|
const relatedSite3 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Analytic3 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Analytic3?.setSite) {
|
|
await Analytic3.setSite(relatedSite3);
|
|
}
|
|
|
|
const relatedSite4 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Analytic4 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Analytic4?.setSite) {
|
|
await Analytic4.setSite(relatedSite4);
|
|
}
|
|
}
|
|
|
|
async function associateAnalyticWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Analytic0 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Analytic0?.setWorkspace) {
|
|
await Analytic0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Analytic1 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Analytic1?.setWorkspace) {
|
|
await Analytic1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Analytic2 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Analytic2?.setWorkspace) {
|
|
await Analytic2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Analytic3 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Analytic3?.setWorkspace) {
|
|
await Analytic3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Analytic4 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Analytic4?.setWorkspace) {
|
|
await Analytic4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateDomainWithSite() {
|
|
const relatedSite0 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Domain0 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Domain0?.setSite) {
|
|
await Domain0.setSite(relatedSite0);
|
|
}
|
|
|
|
const relatedSite1 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Domain1 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Domain1?.setSite) {
|
|
await Domain1.setSite(relatedSite1);
|
|
}
|
|
|
|
const relatedSite2 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Domain2 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Domain2?.setSite) {
|
|
await Domain2.setSite(relatedSite2);
|
|
}
|
|
|
|
const relatedSite3 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Domain3 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Domain3?.setSite) {
|
|
await Domain3.setSite(relatedSite3);
|
|
}
|
|
|
|
const relatedSite4 = await Sites.findOne({
|
|
offset: Math.floor(Math.random() * (await Sites.count())),
|
|
});
|
|
const Domain4 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Domain4?.setSite) {
|
|
await Domain4.setSite(relatedSite4);
|
|
}
|
|
}
|
|
|
|
async function associateDomainWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Domain0 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Domain0?.setWorkspace) {
|
|
await Domain0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Domain1 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Domain1?.setWorkspace) {
|
|
await Domain1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Domain2 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Domain2?.setWorkspace) {
|
|
await Domain2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Domain3 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Domain3?.setWorkspace) {
|
|
await Domain3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Domain4 = await Domains.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Domain4?.setWorkspace) {
|
|
await Domain4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associatePaymentWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Payment0?.setWorkspace) {
|
|
await Payment0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Payment1?.setWorkspace) {
|
|
await Payment1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Payment2?.setWorkspace) {
|
|
await Payment2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment3 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Payment3?.setWorkspace) {
|
|
await Payment3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment4 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Payment4?.setWorkspace) {
|
|
await Payment4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associatePaymentWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Payment0?.setWorkspace) {
|
|
await Payment0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Payment1?.setWorkspace) {
|
|
await Payment1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Payment2?.setWorkspace) {
|
|
await Payment2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment3 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Payment3?.setWorkspace) {
|
|
await Payment3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Payment4 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Payment4?.setWorkspace) {
|
|
await Payment4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateSiteWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site0 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Site0?.setWorkspace) {
|
|
await Site0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site1 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Site1?.setWorkspace) {
|
|
await Site1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site2 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Site2?.setWorkspace) {
|
|
await Site2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site3 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Site3?.setWorkspace) {
|
|
await Site3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site4 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Site4?.setWorkspace) {
|
|
await Site4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateSiteWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site0 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Site0?.setWorkspace) {
|
|
await Site0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site1 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Site1?.setWorkspace) {
|
|
await Site1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site2 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Site2?.setWorkspace) {
|
|
await Site2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site3 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Site3?.setWorkspace) {
|
|
await Site3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const Site4 = await Sites.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Site4?.setWorkspace) {
|
|
await Site4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateSupportTicketWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket0 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (SupportTicket0?.setWorkspace) {
|
|
await SupportTicket0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket1 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (SupportTicket1?.setWorkspace) {
|
|
await SupportTicket1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket2 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (SupportTicket2?.setWorkspace) {
|
|
await SupportTicket2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket3 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (SupportTicket3?.setWorkspace) {
|
|
await SupportTicket3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket4 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (SupportTicket4?.setWorkspace) {
|
|
await SupportTicket4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
async function associateSupportTicketWithWorkspace() {
|
|
const relatedWorkspace0 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket0 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (SupportTicket0?.setWorkspace) {
|
|
await SupportTicket0.setWorkspace(relatedWorkspace0);
|
|
}
|
|
|
|
const relatedWorkspace1 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket1 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (SupportTicket1?.setWorkspace) {
|
|
await SupportTicket1.setWorkspace(relatedWorkspace1);
|
|
}
|
|
|
|
const relatedWorkspace2 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket2 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (SupportTicket2?.setWorkspace) {
|
|
await SupportTicket2.setWorkspace(relatedWorkspace2);
|
|
}
|
|
|
|
const relatedWorkspace3 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket3 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (SupportTicket3?.setWorkspace) {
|
|
await SupportTicket3.setWorkspace(relatedWorkspace3);
|
|
}
|
|
|
|
const relatedWorkspace4 = await Workspaces.findOne({
|
|
offset: Math.floor(Math.random() * (await Workspaces.count())),
|
|
});
|
|
const SupportTicket4 = await SupportTickets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (SupportTicket4?.setWorkspace) {
|
|
await SupportTicket4.setWorkspace(relatedWorkspace4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Analytics.bulkCreate(AnalyticsData);
|
|
|
|
await Domains.bulkCreate(DomainsData);
|
|
|
|
await Payments.bulkCreate(PaymentsData);
|
|
|
|
await Sites.bulkCreate(SitesData);
|
|
|
|
await SupportTickets.bulkCreate(SupportTicketsData);
|
|
|
|
await Workspaces.bulkCreate(WorkspacesData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithWorkspace(),
|
|
|
|
await associateAnalyticWithSite(),
|
|
|
|
await associateAnalyticWithWorkspace(),
|
|
|
|
await associateDomainWithSite(),
|
|
|
|
await associateDomainWithWorkspace(),
|
|
|
|
await associatePaymentWithWorkspace(),
|
|
|
|
await associatePaymentWithWorkspace(),
|
|
|
|
await associateSiteWithWorkspace(),
|
|
|
|
await associateSiteWithWorkspace(),
|
|
|
|
await associateSupportTicketWithWorkspace(),
|
|
|
|
await associateSupportTicketWithWorkspace(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('analytics', null, {});
|
|
|
|
await queryInterface.bulkDelete('domains', null, {});
|
|
|
|
await queryInterface.bulkDelete('payments', null, {});
|
|
|
|
await queryInterface.bulkDelete('sites', null, {});
|
|
|
|
await queryInterface.bulkDelete('support_tickets', null, {});
|
|
|
|
await queryInterface.bulkDelete('workspaces', null, {});
|
|
},
|
|
};
|