930 lines
21 KiB
JavaScript
930 lines
21 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Advisors = db.advisors;
|
|
|
|
const Companies = db.companies;
|
|
|
|
const PersonProfiles = db.person_profiles;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const AdvisorsData = [
|
|
{
|
|
crd_number: 'A12345',
|
|
|
|
first_name: 'George',
|
|
|
|
middle_name: 'H.',
|
|
|
|
last_name: 'Anderson',
|
|
|
|
sec_link: 'https://sec.gov/advisor/georgeanderson',
|
|
|
|
years_of_experience: 15,
|
|
|
|
number_of_firms: 3,
|
|
|
|
number_of_licenses: 5,
|
|
|
|
number_of_disclosures: 0,
|
|
|
|
broker_status: 'Active',
|
|
|
|
broker_status_definition: 'Fully licensed and compliant',
|
|
|
|
report_summary: 'No disclosures or violations.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: 'B67890',
|
|
|
|
first_name: 'Hannah',
|
|
|
|
middle_name: 'J.',
|
|
|
|
last_name: 'Baker',
|
|
|
|
sec_link: 'https://sec.gov/advisor/hannahbaker',
|
|
|
|
years_of_experience: 10,
|
|
|
|
number_of_firms: 2,
|
|
|
|
number_of_licenses: 4,
|
|
|
|
number_of_disclosures: 1,
|
|
|
|
broker_status: 'Active',
|
|
|
|
broker_status_definition: 'Minor disclosure noted',
|
|
|
|
report_summary: 'One minor disclosure, resolved.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: 'C11223',
|
|
|
|
first_name: 'Ian',
|
|
|
|
middle_name: 'K.',
|
|
|
|
last_name: 'Clark',
|
|
|
|
sec_link: 'https://sec.gov/advisor/ianclark',
|
|
|
|
years_of_experience: 20,
|
|
|
|
number_of_firms: 5,
|
|
|
|
number_of_licenses: 6,
|
|
|
|
number_of_disclosures: 0,
|
|
|
|
broker_status: 'Active',
|
|
|
|
broker_status_definition: 'Fully licensed and compliant',
|
|
|
|
report_summary: 'No disclosures or violations.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: 'D44556',
|
|
|
|
first_name: 'Jessica',
|
|
|
|
middle_name: 'L.',
|
|
|
|
last_name: 'Davis',
|
|
|
|
sec_link: 'https://sec.gov/advisor/jessicadavis',
|
|
|
|
years_of_experience: 8,
|
|
|
|
number_of_firms: 1,
|
|
|
|
number_of_licenses: 3,
|
|
|
|
number_of_disclosures: 2,
|
|
|
|
broker_status: 'Active',
|
|
|
|
broker_status_definition: 'Two disclosures noted',
|
|
|
|
report_summary: 'Two disclosures, under review.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: 'E77889',
|
|
|
|
first_name: 'Kevin',
|
|
|
|
middle_name: 'M.',
|
|
|
|
last_name: 'Evans',
|
|
|
|
sec_link: 'https://sec.gov/advisor/kevinsmith',
|
|
|
|
years_of_experience: 12,
|
|
|
|
number_of_firms: 4,
|
|
|
|
number_of_licenses: 5,
|
|
|
|
number_of_disclosures: 0,
|
|
|
|
broker_status: 'Active',
|
|
|
|
broker_status_definition: 'Fully licensed and compliant',
|
|
|
|
report_summary: 'No disclosures or violations.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const CompaniesData = [
|
|
{
|
|
crd_number: '123456',
|
|
|
|
sec_number: '789012',
|
|
|
|
company_name: 'Global Finance Inc.',
|
|
|
|
total_aum: 5000000000,
|
|
|
|
city: 'New York',
|
|
|
|
state: 'NY',
|
|
|
|
address: '123 Wall Street',
|
|
|
|
employee_count: 200,
|
|
|
|
company_size: 'Large',
|
|
|
|
logo_url: 'https://example.com/logos/globalfinance.png',
|
|
|
|
founded_year: 1990,
|
|
|
|
industry: 'Finance',
|
|
|
|
website: 'https://globalfinance.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: '654321',
|
|
|
|
sec_number: '210987',
|
|
|
|
company_name: 'Wealth Solutions LLC',
|
|
|
|
total_aum: 2000000000,
|
|
|
|
city: 'Los Angeles',
|
|
|
|
state: 'CA',
|
|
|
|
address: '456 Sunset Blvd',
|
|
|
|
employee_count: 150,
|
|
|
|
company_size: 'Medium',
|
|
|
|
logo_url: 'https://example.com/logos/wealthsolutions.png',
|
|
|
|
founded_year: 2005,
|
|
|
|
industry: 'Investment',
|
|
|
|
website: 'https://wealthsolutions.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: '112233',
|
|
|
|
sec_number: '445566',
|
|
|
|
company_name: 'Capital Growth Partners',
|
|
|
|
total_aum: 3000000000,
|
|
|
|
city: 'Chicago',
|
|
|
|
state: 'IL',
|
|
|
|
address: '789 Michigan Ave',
|
|
|
|
employee_count: 100,
|
|
|
|
company_size: 'Medium',
|
|
|
|
logo_url: 'https://example.com/logos/capitalgrowth.png',
|
|
|
|
founded_year: 2010,
|
|
|
|
industry: 'Asset Management',
|
|
|
|
website: 'https://capitalgrowth.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: '998877',
|
|
|
|
sec_number: '665544',
|
|
|
|
company_name: 'Investment Strategies Co.',
|
|
|
|
total_aum: 1500000000,
|
|
|
|
city: 'Houston',
|
|
|
|
state: 'TX',
|
|
|
|
address: '321 Main St',
|
|
|
|
employee_count: 80,
|
|
|
|
company_size: 'Small',
|
|
|
|
logo_url: 'https://example.com/logos/investmentstrategies.png',
|
|
|
|
founded_year: 2000,
|
|
|
|
industry: 'Investment',
|
|
|
|
website: 'https://investmentstrategies.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
crd_number: '334455',
|
|
|
|
sec_number: '667788',
|
|
|
|
company_name: 'Future Wealth Advisors',
|
|
|
|
total_aum: 1000000000,
|
|
|
|
city: 'San Francisco',
|
|
|
|
state: 'CA',
|
|
|
|
address: '654 Market St',
|
|
|
|
employee_count: 50,
|
|
|
|
company_size: 'Small',
|
|
|
|
logo_url: 'https://example.com/logos/futurewealth.png',
|
|
|
|
founded_year: 2015,
|
|
|
|
industry: 'Wealth Management',
|
|
|
|
website: 'https://futurewealth.com',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PersonProfilesData = [
|
|
{
|
|
first_name: 'Alice',
|
|
|
|
last_name: 'Williams',
|
|
|
|
email: 'alice.williams@example.com',
|
|
|
|
email_verification_status: 'Verified',
|
|
|
|
primary_email_catch_all_status: 'Active',
|
|
|
|
linkedin_headline: 'Experienced Financial Advisor',
|
|
|
|
linkedin_summary: 'Over 10 years in wealth management.',
|
|
|
|
location: 'New York, NY',
|
|
|
|
linkedin_url: 'https://linkedin.com/in/alicewilliams',
|
|
|
|
picture_url: 'https://example.com/pictures/alice.jpg',
|
|
|
|
jobs_role_count: 5,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Bob',
|
|
|
|
last_name: 'Taylor',
|
|
|
|
email: 'bob.taylor@example.com',
|
|
|
|
email_verification_status: 'Pending',
|
|
|
|
primary_email_catch_all_status: 'Inactive',
|
|
|
|
linkedin_headline: 'Investment Specialist',
|
|
|
|
linkedin_summary: 'Specializes in high-net-worth clients.',
|
|
|
|
location: 'San Francisco, CA',
|
|
|
|
linkedin_url: 'https://linkedin.com/in/bobtaylor',
|
|
|
|
picture_url: 'https://example.com/pictures/bob.jpg',
|
|
|
|
jobs_role_count: 3,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Charlie',
|
|
|
|
last_name: 'Davis',
|
|
|
|
email: 'charlie.davis@example.com',
|
|
|
|
email_verification_status: 'Verified',
|
|
|
|
primary_email_catch_all_status: 'Active',
|
|
|
|
linkedin_headline: 'Portfolio Manager',
|
|
|
|
linkedin_summary: 'Focus on sustainable investments.',
|
|
|
|
location: 'Chicago, IL',
|
|
|
|
linkedin_url: 'https://linkedin.com/in/charliedavis',
|
|
|
|
picture_url: 'https://example.com/pictures/charlie.jpg',
|
|
|
|
jobs_role_count: 4,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Diana',
|
|
|
|
last_name: 'Miller',
|
|
|
|
email: 'diana.miller@example.com',
|
|
|
|
email_verification_status: 'Verified',
|
|
|
|
primary_email_catch_all_status: 'Active',
|
|
|
|
linkedin_headline: 'Financial Consultant',
|
|
|
|
linkedin_summary: 'Expert in retirement planning.',
|
|
|
|
location: 'Boston, MA',
|
|
|
|
linkedin_url: 'https://linkedin.com/in/dianamiller',
|
|
|
|
picture_url: 'https://example.com/pictures/diana.jpg',
|
|
|
|
jobs_role_count: 6,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Ethan',
|
|
|
|
last_name: 'Wilson',
|
|
|
|
email: 'ethan.wilson@example.com',
|
|
|
|
email_verification_status: 'Pending',
|
|
|
|
primary_email_catch_all_status: 'Inactive',
|
|
|
|
linkedin_headline: 'Wealth Manager',
|
|
|
|
linkedin_summary: 'Dedicated to client success.',
|
|
|
|
location: 'Miami, FL',
|
|
|
|
linkedin_url: 'https://linkedin.com/in/ethanwilson',
|
|
|
|
picture_url: 'https://example.com/pictures/ethan.jpg',
|
|
|
|
jobs_role_count: 2,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Finance Corp',
|
|
},
|
|
|
|
{
|
|
name: 'Wealth Advisors',
|
|
},
|
|
|
|
{
|
|
name: 'Investment Group',
|
|
},
|
|
|
|
{
|
|
name: 'Capital Partners',
|
|
},
|
|
|
|
{
|
|
name: 'Asset Management',
|
|
},
|
|
];
|
|
|
|
// 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 associateAdvisorWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor0 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Advisor0?.setOrganization) {
|
|
await Advisor0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor1 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Advisor1?.setOrganization) {
|
|
await Advisor1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor2 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Advisor2?.setOrganization) {
|
|
await Advisor2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor3 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Advisor3?.setOrganization) {
|
|
await Advisor3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor4 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Advisor4?.setOrganization) {
|
|
await Advisor4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateAdvisorWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor0 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Advisor0?.setOrganization) {
|
|
await Advisor0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor1 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Advisor1?.setOrganization) {
|
|
await Advisor1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor2 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Advisor2?.setOrganization) {
|
|
await Advisor2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor3 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Advisor3?.setOrganization) {
|
|
await Advisor3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Advisor4 = await Advisors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Advisor4?.setOrganization) {
|
|
await Advisor4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateCompanyWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company0 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Company0?.setOrganization) {
|
|
await Company0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company1 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Company1?.setOrganization) {
|
|
await Company1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company2 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Company2?.setOrganization) {
|
|
await Company2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company3 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Company3?.setOrganization) {
|
|
await Company3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company4 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Company4?.setOrganization) {
|
|
await Company4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateCompanyWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company0 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Company0?.setOrganization) {
|
|
await Company0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company1 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Company1?.setOrganization) {
|
|
await Company1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company2 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Company2?.setOrganization) {
|
|
await Company2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company3 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Company3?.setOrganization) {
|
|
await Company3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Company4 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Company4?.setOrganization) {
|
|
await Company4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePersonProfileWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile0 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PersonProfile0?.setOrganization) {
|
|
await PersonProfile0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile1 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PersonProfile1?.setOrganization) {
|
|
await PersonProfile1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile2 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PersonProfile2?.setOrganization) {
|
|
await PersonProfile2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile3 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PersonProfile3?.setOrganization) {
|
|
await PersonProfile3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile4 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PersonProfile4?.setOrganization) {
|
|
await PersonProfile4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePersonProfileWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile0 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PersonProfile0?.setOrganization) {
|
|
await PersonProfile0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile1 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PersonProfile1?.setOrganization) {
|
|
await PersonProfile1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile2 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PersonProfile2?.setOrganization) {
|
|
await PersonProfile2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile3 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PersonProfile3?.setOrganization) {
|
|
await PersonProfile3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const PersonProfile4 = await PersonProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PersonProfile4?.setOrganization) {
|
|
await PersonProfile4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Advisors.bulkCreate(AdvisorsData);
|
|
|
|
await Companies.bulkCreate(CompaniesData);
|
|
|
|
await PersonProfiles.bulkCreate(PersonProfilesData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateAdvisorWithOrganization(),
|
|
|
|
await associateAdvisorWithOrganization(),
|
|
|
|
await associateCompanyWithOrganization(),
|
|
|
|
await associateCompanyWithOrganization(),
|
|
|
|
await associatePersonProfileWithOrganization(),
|
|
|
|
await associatePersonProfileWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('advisors', null, {});
|
|
|
|
await queryInterface.bulkDelete('companies', null, {});
|
|
|
|
await queryInterface.bulkDelete('person_profiles', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|