39901-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-05-05 08:56:46 +00:00

5772 lines
105 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const LandingPages = db.landing_pages;
const LandingSections = db.landing_sections;
const Services = db.services;
const Leads = db.leads;
const LeadAttachments = db.lead_attachments;
const Conversations = db.conversations;
const ConversationMessages = db.conversation_messages;
const Campaigns = db.campaigns;
const TrackingEvents = db.tracking_events;
const Assets = db.assets;
const Integrations = db.integrations;
const LandingPagesData = [
{
"name": "Pro Landing Main",
"slug": "pro-landing",
"status": "archived",
// type code here for "images" field
"hero_headline": "Convert visitors into qualified leads",
"hero_subheadline": "Premium landing pages with fast PHP friendly integrations and conversion focused UX.",
"primary_cta_text": "Request a quote",
"primary_cta_url": "/#contact",
"secondary_cta_text": "See services",
"secondary_cta_url": "/#services",
"value_proposition": "We design and build high converting landing pages with clear messaging, analytics, and lead capture workflows.",
"seo_title": "Pro Landing and Backend Lead Capture",
"seo_description": "Professional landing page with lead capture, tracking, and integrations.",
// type code here for "relation_many" field
},
{
"name": "AI Tools Landing",
"slug": "ai-tools",
"status": "draft",
// type code here for "images" field
"hero_headline": "AI assisted content and design",
"hero_subheadline": "Use proven tools to ship faster without sacrificing quality.",
"primary_cta_text": "Book a call",
"primary_cta_url": "/#contact",
"secondary_cta_text": "View examples",
"secondary_cta_url": "/#work",
"value_proposition": "We combine AI powered copy, visuals, and UX testing to optimize conversion.",
"seo_title": "AI assisted landing pages",
"seo_description": "AI assisted landing page creation with measurable outcomes.",
// type code here for "relation_many" field
},
{
"name": "Lead Gen for Agencies",
"slug": "agencies",
"status": "draft",
// type code here for "images" field
"hero_headline": "Lead gen pages for busy agencies",
"hero_subheadline": "Ready to deploy landing pages that match your brand and pipeline.",
"primary_cta_text": "Get started",
"primary_cta_url": "/#contact",
"secondary_cta_text": "Pricing",
"secondary_cta_url": "/#pricing",
"value_proposition": "White label friendly landing pages with clean handoff and tracking.",
"seo_title": "Agency lead generation landing pages",
"seo_description": "Landing pages for agencies with tracking and forms.",
// type code here for "relation_many" field
},
{
"name": "Conversion Audit Offer",
"slug": "conversion-audit",
"status": "draft",
// type code here for "images" field
"hero_headline": "Find what is blocking conversions",
"hero_subheadline": "Predictive attention insights and copy improvements in days.",
"primary_cta_text": "Request audit",
"primary_cta_url": "/#contact",
"secondary_cta_text": "How it works",
"secondary_cta_url": "/#process",
"value_proposition": "We review messaging, layout, and conversion paths and deliver actionable fixes.",
"seo_title": "Conversion audit and optimization",
"seo_description": "Conversion audit using analytics and copy performance scoring.",
// type code here for "relation_many" field
},
{
"name": "Maintenance and Updates",
"slug": "maintenance",
"status": "published",
// type code here for "images" field
"hero_headline": "Keep your landing pages fresh",
"hero_subheadline": "Ongoing edits, A B tests, and performance improvements.",
"primary_cta_text": "Contact us",
"primary_cta_url": "/#contact",
"secondary_cta_text": "Learn more",
"secondary_cta_url": "/#about",
"value_proposition": "Monthly updates to keep campaigns effective and content current.",
"seo_title": "Landing page maintenance",
"seo_description": "Maintenance plans for landing pages and tracking.",
// type code here for "relation_many" field
},
];
const LandingSectionsData = [
{
// type code here for "relation_one" field
"sort_order": 1,
"section_type": "custom",
"title": "Hero",
"subtitle": "Clear offer and strong CTA",
"content": "Headline, benefits, and call to action above the fold.",
// type code here for "images" field
// type code here for "files" field
"button_text": "Request a quote",
"button_url": "/#contact",
"is_enabled": true,
},
{
// type code here for "relation_one" field
"sort_order": 2,
"section_type": "social_proof",
"title": "Features",
"subtitle": "What you get",
"content": "Fast build, clean code, analytics, and lead routing.",
// type code here for "images" field
// type code here for "files" field
"button_text": "See services",
"button_url": "/#services",
"is_enabled": true,
},
{
// type code here for "relation_one" field
"sort_order": 3,
"section_type": "benefits",
"title": "Results",
"subtitle": "Proof that builds trust",
"content": "Selected outcomes, testimonials, and logos.",
// type code here for "images" field
// type code here for "files" field
"button_text": "View case studies",
"button_url": "/#work",
"is_enabled": true,
},
{
// type code here for "relation_one" field
"sort_order": 1,
"section_type": "about",
"title": "Process",
"subtitle": "From audit to fixes",
"content": "We collect data, review the page, then deliver a prioritized action plan.",
// type code here for "images" field
// type code here for "files" field
"button_text": "Request audit",
"button_url": "/#contact",
"is_enabled": true,
},
{
// type code here for "relation_one" field
"sort_order": 1,
"section_type": "pricing",
"title": "Pricing",
"subtitle": "Transparent starting points",
"content": "Starter, Growth, and Custom packages depending on scope.",
// type code here for "images" field
// type code here for "files" field
"button_text": "Get started",
"button_url": "/#contact",
"is_enabled": true,
},
];
const ServicesData = [
{
"name": "Landing Page Design and Build",
"short_description": "Conversion focused landing page with form and tracking.",
"description": "Design and build a responsive landing page with clear messaging, analytics events, and lead capture.",
"starting_price": 2500,
"billing_model": "subscription",
"delivery_days_estimate": 10,
// type code here for "images" field
"is_active": true,
},
{
"name": "Conversion Audit",
"short_description": "UX and copy review with prioritized fixes.",
"description": "Audit layout, hierarchy, copy, and CTA flow using predictive attention and copy scoring tools.",
"starting_price": 950,
"billing_model": "quote_only",
"delivery_days_estimate": 5,
// type code here for "images" field
"is_active": true,
},
{
"name": "Copywriting Package",
"short_description": "High quality landing copy and variants.",
"description": "Landing page copy with multiple headline and CTA variants, optimized for clarity and conversion.",
"starting_price": 600,
"billing_model": "subscription",
"delivery_days_estimate": 4,
// type code here for "images" field
"is_active": true,
},
{
"name": "Tracking and Analytics Setup",
"short_description": "Events, UTM hygiene, and dashboards.",
"description": "Implement tracking events, UTM conventions, and a lightweight reporting view for campaigns.",
"starting_price": 400,
"billing_model": "hourly",
"delivery_days_estimate": 3,
// type code here for "images" field
"is_active": true,
},
{
"name": "Ongoing Optimization Retainer",
"short_description": "Monthly improvements and tests.",
"description": "Monthly content updates, experiments, and performance reviews to continually improve conversion rates.",
"starting_price": 1200,
"billing_model": "fixed",
"delivery_days_estimate": 30,
// type code here for "images" field
"is_active": true,
},
];
const LeadsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Claire Dubois",
"email": "claire.dubois@atelier-cd.fr",
"phone": "+33 6 12 34 56 78",
"company": "Atelier CD",
"website_url": "https://atelier-cd.fr",
"lead_source": "landing_form",
"status": "won",
"message": "We need a premium landing page for a new offer with a simple quote form.",
"budget_amount": 3000,
"budget_currency": "GBP",
"submitted_at": new Date('2026-04-28T10:15:00Z'),
"last_contacted_at": new Date('2026-04-28T16:40:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Omar El Fassi",
"email": "omar@northpeak.ma",
"phone": "+212 6 61 22 33 44",
"company": "NorthPeak",
"website_url": "https://northpeak.ma",
"lead_source": "referral",
"status": "won",
"message": "We want an audit and quick fixes for our existing page before launching ads.",
"budget_amount": 1200,
"budget_currency": "OTHER",
"submitted_at": new Date('2026-04-27T09:05:00Z'),
"last_contacted_at": new Date('2026-04-29T11:20:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Michael Carter",
"email": "michael.carter@brightwaveagency.com",
"phone": "+1 415 555 0199",
"company": "BrightWave Agency",
"website_url": "https://brightwaveagency.com",
"lead_source": "other",
"status": "lost",
"message": "We need reliable tracking events and UTM structure across several landing pages.",
"budget_amount": 800,
"budget_currency": "XAF",
"submitted_at": new Date('2026-04-23T14:30:00Z'),
"last_contacted_at": new Date('2026-04-24T09:10:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Lina Svensson",
"email": "lina@solstudi.se",
"phone": "+46 70 123 45 67",
"company": "Sol Studio",
"website_url": "https://solstudi.se",
"lead_source": "email",
"status": "contacted",
"message": "Looking for landing copy in English with variations for A B testing.",
"budget_amount": 700,
"budget_currency": "USD",
"submitted_at": new Date('2026-04-21T12:00:00Z'),
"last_contacted_at": new Date('2026-04-22T10:35:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Grace Kim",
"email": "grace.kim@riverstone.io",
"phone": "+1 212 555 0144",
"company": "Riverstone",
"website_url": "https://riverstone.io",
"lead_source": "phone_call",
"status": "proposal_sent",
"message": "We want monthly optimization with reporting for our lead gen funnel.",
"budget_amount": 1500,
"budget_currency": "USD",
"submitted_at": new Date('2026-04-10T16:22:00Z'),
"last_contacted_at": new Date('2026-04-11T13:05:00Z'),
// type code here for "relation_one" field
// type code here for "relation_many" field
},
];
const LeadAttachmentsData = [
{
// type code here for "relation_one" field
// type code here for "files" field
"filename": "brief-atelier-cd.pdf",
"note": "Initial brief and brand notes",
"uploaded_at": new Date('2026-04-28T10:18:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "files" field
"filename": "northpeak-landing-screenshot.png",
"note": "Current landing page screenshot",
"uploaded_at": new Date('2026-04-27T09:08:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "files" field
"filename": "utm-conventions.xlsx",
"note": "Existing UTM conventions document",
"uploaded_at": new Date('2026-04-23T14:34:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "files" field
"filename": "tone-of-voice-guidelines.pdf",
"note": "Brand voice and terminology",
"uploaded_at": new Date('2026-04-21T12:05:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "files" field
"filename": "kpi-dashboard-link.txt",
"note": "Dashboard link and KPI list",
"uploaded_at": new Date('2026-04-10T16:30:00Z'),
},
];
const ConversationsData = [
{
// type code here for "relation_one" field
"channel": "phone",
"subject": "Landing page scope and timeline",
"summary": "Discussed page goals, target audience, and required sections. Agreed on a 10 day delivery plan.",
"started_at": new Date('2026-04-28T16:45:00Z'),
"ended_at": new Date('2026-04-28T17:05:00Z'),
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"channel": "other",
"subject": "Conversion audit kickoff",
"summary": "Reviewed traffic sources and main conversion issues. Next step is analytics review and heatmap prediction.",
"started_at": new Date('2026-04-29T11:30:00Z'),
"ended_at": new Date('2026-04-29T12:00:00Z'),
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"channel": "sms",
"subject": "Tracking requirements discovery",
"summary": "Listed required events, naming scheme, and handoff process for agency clients.",
"started_at": new Date('2026-04-24T09:15:00Z'),
"ended_at": new Date('2026-04-24T09:40:00Z'),
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"channel": "chatbot",
"subject": "Copywriting deliverables",
"summary": "Confirmed tone, structure, and number of variants for headlines and CTAs.",
"started_at": new Date('2026-04-22T10:40:00Z'),
"ended_at": new Date('2026-04-22T10:55:00Z'),
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"channel": "email",
"subject": "Retainer onboarding",
"summary": "Aligned on monthly cadence, reporting, and experiment backlog. Set first review date.",
"started_at": new Date('2026-04-11T13:15:00Z'),
"ended_at": new Date('2026-04-11T13:45:00Z'),
// type code here for "relation_many" field
},
];
const ConversationMessagesData = [
{
// type code here for "relation_one" field
"sender_type": "system",
// type code here for "relation_one" field
"sender_name": "Sara Diallo",
"sender_email": "sara.diallo@prolanding.io",
"message_text": "Thanks for the details. Please share any brand assets and the primary conversion goal for the page.",
"sent_at": new Date('2026-04-28T16:46:00Z'),
"is_internal_note": false,
// type code here for "files" field
},
{
// type code here for "relation_one" field
"sender_type": "agent",
// type code here for "relation_one" field
"sender_name": "Claire Dubois",
"sender_email": "claire.dubois@atelier-cd.fr",
"message_text": "Primary goal is quote requests. Brand assets are ready and we can send them today.",
"sent_at": new Date('2026-04-28T16:50:00Z'),
"is_internal_note": false,
// type code here for "files" field
},
{
// type code here for "relation_one" field
"sender_type": "system",
// type code here for "relation_one" field
"sender_name": "Nadia Benali",
"sender_email": "nadia.benali@prolanding.io",
"message_text": "We will start with event tracking review and then share a prioritized list of fixes within 5 days.",
"sent_at": new Date('2026-04-29T11:32:00Z'),
"is_internal_note": false,
// type code here for "files" field
},
{
// type code here for "relation_one" field
"sender_type": "system",
// type code here for "relation_one" field
"sender_name": "Thomas Nguyen",
"sender_email": "thomas.nguyen@prolanding.io",
"message_text": "Please confirm whether you need server side events in addition to client side tracking.",
"sent_at": new Date('2026-04-24T09:20:00Z'),
"is_internal_note": true,
// type code here for "files" field
},
{
// type code here for "relation_one" field
"sender_type": "system",
// type code here for "relation_one" field
"sender_name": "Julien Moreau",
"sender_email": "julien.moreau@prolanding.io",
"message_text": "We will deliver 3 headline options, 3 CTA options, and a full page draft for review.",
"sent_at": new Date('2026-04-22T10:41:00Z'),
"is_internal_note": true,
// type code here for "files" field
},
];
const CampaignsData = [
{
"name": "Spring Lead Gen 2026",
"channel": "referral",
"start_at": new Date('2026-03-15T00:00:00Z'),
"end_at": new Date('2026-05-15T00:00:00Z'),
"budget_amount": 2500,
"budget_currency": "GBP",
"status": "archived",
// type code here for "relation_many" field
},
{
"name": "SEO Content Push",
"channel": "social",
"start_at": new Date('2026-02-01T00:00:00Z'),
"end_at": new Date('2026-06-01T00:00:00Z'),
"budget_amount": 0,
"budget_currency": "USD",
"status": "completed",
// type code here for "relation_many" field
},
{
"name": "Agency Partner Referrals",
"channel": "seo",
"start_at": new Date('2026-01-10T00:00:00Z'),
"end_at": new Date('2026-12-31T00:00:00Z'),
"budget_amount": 500,
"budget_currency": "AUD",
"status": "completed",
// type code here for "relation_many" field
},
{
"name": "Email Nurture Series Q2",
"channel": "email",
"start_at": new Date('2026-04-01T00:00:00Z'),
"end_at": new Date('2026-06-30T00:00:00Z'),
"budget_amount": 150,
"budget_currency": "XAF",
"status": "planned",
// type code here for "relation_many" field
},
{
"name": "Social Proof Clips",
"channel": "email",
"start_at": new Date('2026-03-01T00:00:00Z'),
"end_at": new Date('2026-04-30T00:00:00Z'),
"budget_amount": 300,
"budget_currency": "EUR",
"status": "completed",
// type code here for "relation_many" field
},
];
const TrackingEventsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "chat_submit",
"visitor_id": "v_2f3a91",
"session_id": "s_8a1c22",
"referrer_url": "https://www.google.com",
"utm_source": "google",
"utm_medium": "cpc",
"utm_campaign": "spring_lead_gen_2026",
"utm_term": "landing page agency",
"utm_content": "ad_variant_1",
"page_url": "https://prolanding.io/pro-landing",
"occurred_at": new Date('2026-04-28T10:12:10Z'),
"attention_score": 72.4,
"user_agent": "Mozilla/5.0 Chrome",
"ip_address": "203.0.113.10",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "chat_submit",
"visitor_id": "v_2f3a91",
"session_id": "s_8a1c22",
"referrer_url": "https://www.google.com",
"utm_source": "google",
"utm_medium": "cpc",
"utm_campaign": "spring_lead_gen_2026",
"utm_term": "landing page agency",
"utm_content": "ad_variant_1",
"page_url": "https://prolanding.io/pro-landing#contact",
"occurred_at": new Date('2026-04-28T10:13:02Z'),
"attention_score": 74.1,
"user_agent": "Mozilla/5.0 Chrome",
"ip_address": "203.0.113.10",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "form_submit",
"visitor_id": "v_91bd02",
"session_id": "s_19df77",
"referrer_url": "https://duckduckgo.com",
"utm_source": "organic",
"utm_medium": "seo",
"utm_campaign": "seo_audit",
"utm_term": "conversion audit",
"utm_content": "blog_link",
"page_url": "https://prolanding.io/conversion-audit",
"occurred_at": new Date('2026-04-27T08:58:45Z'),
"attention_score": 68.9,
"user_agent": "Mozilla/5.0 Safari",
"ip_address": "198.51.100.44",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "other",
"visitor_id": "v_6c0e5b",
"session_id": "s_0b7a9a",
"referrer_url": "https://brightwaveagency.com",
"utm_source": "partner",
"utm_medium": "referral",
"utm_campaign": "agency_partners",
"utm_term": "leadgen",
"utm_content": "footer_link",
"page_url": "https://prolanding.io/agencies#contact",
"occurred_at": new Date('2026-04-23T14:27:19Z'),
"attention_score": 61.2,
"user_agent": "Mozilla/5.0 Firefox",
"ip_address": "192.0.2.77",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "page_view",
"visitor_id": "v_4ad1cc",
"session_id": "s_5eaa12",
"referrer_url": "https://mail.example.com",
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "q2_nurture",
"utm_term": "ai_landing",
"utm_content": "cta_button",
"page_url": "https://prolanding.io/ai-tools#contact",
"occurred_at": new Date('2026-04-21T11:59:40Z'),
"attention_score": 70.3,
"user_agent": "Mozilla/5.0 Chrome",
"ip_address": "203.0.113.88",
},
];
const AssetsData = [
{
"name": "Primary Logo Pack",
"asset_type": "other",
"source_tool": "other",
// type code here for "images" field
// type code here for "files" field
"license_notes": "Logo files and usage notes for web and print.",
// type code here for "relation_one" field
"created_on": new Date('2026-03-05T10:00:00Z'),
},
{
"name": "Brand Guidelines PDF",
"asset_type": "logo",
"source_tool": "synthesia",
// type code here for "images" field
// type code here for "files" field
"license_notes": "Colors, typography, and layout rules.",
// type code here for "relation_one" field
"created_on": new Date('2026-03-06T14:20:00Z'),
},
{
"name": "Hero Illustration Set",
"asset_type": "image",
"source_tool": "figma",
// type code here for "images" field
// type code here for "files" field
"license_notes": "Generated illustrations for hero sections.",
// type code here for "relation_one" field
"created_on": new Date('2026-03-12T09:35:00Z'),
},
{
"name": "Testimonial Clips Batch 1",
"asset_type": "other",
"source_tool": "other",
// type code here for "images" field
// type code here for "files" field
"license_notes": "Short video clips for social proof section.",
// type code here for "relation_one" field
"created_on": new Date('2026-03-20T16:05:00Z'),
},
{
"name": "Abstract Background Collection",
"asset_type": "logo",
"source_tool": "figma",
// type code here for "images" field
// type code here for "files" field
"license_notes": "Abstract backgrounds for sections and ads.",
// type code here for "relation_one" field
"created_on": new Date('2026-04-02T11:10:00Z'),
},
];
const IntegrationsData = [
{
"name": "Tidio Chat Widget",
"provider": "copy_ai",
"status": "disabled",
"api_key_hint": "tidio_key_ending_93A1",
"webhook_url": "https://api.prolanding.io/webhooks/tidio",
"is_sandbox": false,
"last_synced_at": new Date('2026-04-26T08:00:00Z'),
"notes": "Chat triggers on pricing and contact sections.",
},
{
"name": "Lyro AI Assistant",
"provider": "other",
"status": "disabled",
"api_key_hint": "lyro_key_ending_11BC",
"webhook_url": "https://api.prolanding.io/webhooks/lyro",
"is_sandbox": true,
"last_synced_at": new Date('2026-04-10T08:00:00Z'),
"notes": "Enable after final FAQ is published.",
},
{
"name": "Attention Insight",
"provider": "anyword",
"status": "disabled",
"api_key_hint": "ai_key_ending_7F2D",
"webhook_url": "https://api.prolanding.io/webhooks/attention-insight",
"is_sandbox": true,
"last_synced_at": new Date('2026-04-25T18:30:00Z'),
"notes": "Used for predictive heatmaps on hero and pricing sections.",
},
{
"name": "Surfer AI",
"provider": "lyro",
"status": "error",
"api_key_hint": "surfer_key_ending_5C9E",
"webhook_url": "https://api.prolanding.io/webhooks/surfer",
"is_sandbox": true,
"last_synced_at": new Date('2026-04-22T07:45:00Z'),
"notes": "Content briefs and SEO recommendations for service pages.",
},
{
"name": "WordPress 10Web",
"provider": "jasper_ai",
"status": "error",
"api_key_hint": "10web_key_ending_0A44",
"webhook_url": "https://api.prolanding.io/webhooks/10web",
"is_sandbox": true,
"last_synced_at": new Date('2026-04-18T12:05:00Z'),
"notes": "Sync paused due to authentication error. Refresh token required.",
},
];
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateLandingSectionWithLanding_page() {
const relatedLanding_page0 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const LandingSection0 = await LandingSections.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LandingSection0?.setLanding_page)
{
await
LandingSection0.
setLanding_page(relatedLanding_page0);
}
const relatedLanding_page1 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const LandingSection1 = await LandingSections.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LandingSection1?.setLanding_page)
{
await
LandingSection1.
setLanding_page(relatedLanding_page1);
}
const relatedLanding_page2 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const LandingSection2 = await LandingSections.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LandingSection2?.setLanding_page)
{
await
LandingSection2.
setLanding_page(relatedLanding_page2);
}
const relatedLanding_page3 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const LandingSection3 = await LandingSections.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (LandingSection3?.setLanding_page)
{
await
LandingSection3.
setLanding_page(relatedLanding_page3);
}
const relatedLanding_page4 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const LandingSection4 = await LandingSections.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (LandingSection4?.setLanding_page)
{
await
LandingSection4.
setLanding_page(relatedLanding_page4);
}
}
async function associateLeadWithLanding_page() {
const relatedLanding_page0 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const Lead0 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Lead0?.setLanding_page)
{
await
Lead0.
setLanding_page(relatedLanding_page0);
}
const relatedLanding_page1 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const Lead1 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Lead1?.setLanding_page)
{
await
Lead1.
setLanding_page(relatedLanding_page1);
}
const relatedLanding_page2 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const Lead2 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Lead2?.setLanding_page)
{
await
Lead2.
setLanding_page(relatedLanding_page2);
}
const relatedLanding_page3 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const Lead3 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Lead3?.setLanding_page)
{
await
Lead3.
setLanding_page(relatedLanding_page3);
}
const relatedLanding_page4 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Lead4?.setLanding_page)
{
await
Lead4.
setLanding_page(relatedLanding_page4);
}
}
async function associateLeadWithService() {
const relatedService0 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const Lead0 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Lead0?.setService)
{
await
Lead0.
setService(relatedService0);
}
const relatedService1 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const Lead1 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Lead1?.setService)
{
await
Lead1.
setService(relatedService1);
}
const relatedService2 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const Lead2 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Lead2?.setService)
{
await
Lead2.
setService(relatedService2);
}
const relatedService3 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const Lead3 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Lead3?.setService)
{
await
Lead3.
setService(relatedService3);
}
const relatedService4 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Lead4?.setService)
{
await
Lead4.
setService(relatedService4);
}
}
async function associateLeadWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead0 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Lead0?.setAssigned_to)
{
await
Lead0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead1 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Lead1?.setAssigned_to)
{
await
Lead1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead2 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Lead2?.setAssigned_to)
{
await
Lead2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead3 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Lead3?.setAssigned_to)
{
await
Lead3.
setAssigned_to(relatedAssigned_to3);
}
const relatedAssigned_to4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Lead4?.setAssigned_to)
{
await
Lead4.
setAssigned_to(relatedAssigned_to4);
}
}
// Similar logic for "relation_many"
async function associateLeadAttachmentWithLead() {
const relatedLead0 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const LeadAttachment0 = await LeadAttachments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LeadAttachment0?.setLead)
{
await
LeadAttachment0.
setLead(relatedLead0);
}
const relatedLead1 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const LeadAttachment1 = await LeadAttachments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LeadAttachment1?.setLead)
{
await
LeadAttachment1.
setLead(relatedLead1);
}
const relatedLead2 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const LeadAttachment2 = await LeadAttachments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LeadAttachment2?.setLead)
{
await
LeadAttachment2.
setLead(relatedLead2);
}
const relatedLead3 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const LeadAttachment3 = await LeadAttachments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (LeadAttachment3?.setLead)
{
await
LeadAttachment3.
setLead(relatedLead3);
}
const relatedLead4 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const LeadAttachment4 = await LeadAttachments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (LeadAttachment4?.setLead)
{
await
LeadAttachment4.
setLead(relatedLead4);
}
}
async function associateConversationWithLead() {
const relatedLead0 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const Conversation0 = await Conversations.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Conversation0?.setLead)
{
await
Conversation0.
setLead(relatedLead0);
}
const relatedLead1 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const Conversation1 = await Conversations.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Conversation1?.setLead)
{
await
Conversation1.
setLead(relatedLead1);
}
const relatedLead2 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const Conversation2 = await Conversations.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Conversation2?.setLead)
{
await
Conversation2.
setLead(relatedLead2);
}
const relatedLead3 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const Conversation3 = await Conversations.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Conversation3?.setLead)
{
await
Conversation3.
setLead(relatedLead3);
}
const relatedLead4 = await Leads.findOne({
offset: Math.floor(Math.random() * (await Leads.count())),
});
const Conversation4 = await Conversations.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Conversation4?.setLead)
{
await
Conversation4.
setLead(relatedLead4);
}
}
// Similar logic for "relation_many"
async function associateConversationMessageWithConversation() {
const relatedConversation0 = await Conversations.findOne({
offset: Math.floor(Math.random() * (await Conversations.count())),
});
const ConversationMessage0 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ConversationMessage0?.setConversation)
{
await
ConversationMessage0.
setConversation(relatedConversation0);
}
const relatedConversation1 = await Conversations.findOne({
offset: Math.floor(Math.random() * (await Conversations.count())),
});
const ConversationMessage1 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ConversationMessage1?.setConversation)
{
await
ConversationMessage1.
setConversation(relatedConversation1);
}
const relatedConversation2 = await Conversations.findOne({
offset: Math.floor(Math.random() * (await Conversations.count())),
});
const ConversationMessage2 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ConversationMessage2?.setConversation)
{
await
ConversationMessage2.
setConversation(relatedConversation2);
}
const relatedConversation3 = await Conversations.findOne({
offset: Math.floor(Math.random() * (await Conversations.count())),
});
const ConversationMessage3 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ConversationMessage3?.setConversation)
{
await
ConversationMessage3.
setConversation(relatedConversation3);
}
const relatedConversation4 = await Conversations.findOne({
offset: Math.floor(Math.random() * (await Conversations.count())),
});
const ConversationMessage4 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ConversationMessage4?.setConversation)
{
await
ConversationMessage4.
setConversation(relatedConversation4);
}
}
async function associateConversationMessageWithAgent_user() {
const relatedAgent_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ConversationMessage0 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ConversationMessage0?.setAgent_user)
{
await
ConversationMessage0.
setAgent_user(relatedAgent_user0);
}
const relatedAgent_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ConversationMessage1 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ConversationMessage1?.setAgent_user)
{
await
ConversationMessage1.
setAgent_user(relatedAgent_user1);
}
const relatedAgent_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ConversationMessage2 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ConversationMessage2?.setAgent_user)
{
await
ConversationMessage2.
setAgent_user(relatedAgent_user2);
}
const relatedAgent_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ConversationMessage3 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ConversationMessage3?.setAgent_user)
{
await
ConversationMessage3.
setAgent_user(relatedAgent_user3);
}
const relatedAgent_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ConversationMessage4 = await ConversationMessages.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ConversationMessage4?.setAgent_user)
{
await
ConversationMessage4.
setAgent_user(relatedAgent_user4);
}
}
// Similar logic for "relation_many"
async function associateTrackingEventWithCampaign() {
const relatedCampaign0 = await Campaigns.findOne({
offset: Math.floor(Math.random() * (await Campaigns.count())),
});
const TrackingEvent0 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TrackingEvent0?.setCampaign)
{
await
TrackingEvent0.
setCampaign(relatedCampaign0);
}
const relatedCampaign1 = await Campaigns.findOne({
offset: Math.floor(Math.random() * (await Campaigns.count())),
});
const TrackingEvent1 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TrackingEvent1?.setCampaign)
{
await
TrackingEvent1.
setCampaign(relatedCampaign1);
}
const relatedCampaign2 = await Campaigns.findOne({
offset: Math.floor(Math.random() * (await Campaigns.count())),
});
const TrackingEvent2 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TrackingEvent2?.setCampaign)
{
await
TrackingEvent2.
setCampaign(relatedCampaign2);
}
const relatedCampaign3 = await Campaigns.findOne({
offset: Math.floor(Math.random() * (await Campaigns.count())),
});
const TrackingEvent3 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TrackingEvent3?.setCampaign)
{
await
TrackingEvent3.
setCampaign(relatedCampaign3);
}
const relatedCampaign4 = await Campaigns.findOne({
offset: Math.floor(Math.random() * (await Campaigns.count())),
});
const TrackingEvent4 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (TrackingEvent4?.setCampaign)
{
await
TrackingEvent4.
setCampaign(relatedCampaign4);
}
}
async function associateTrackingEventWithLanding_page() {
const relatedLanding_page0 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const TrackingEvent0 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TrackingEvent0?.setLanding_page)
{
await
TrackingEvent0.
setLanding_page(relatedLanding_page0);
}
const relatedLanding_page1 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const TrackingEvent1 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TrackingEvent1?.setLanding_page)
{
await
TrackingEvent1.
setLanding_page(relatedLanding_page1);
}
const relatedLanding_page2 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const TrackingEvent2 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TrackingEvent2?.setLanding_page)
{
await
TrackingEvent2.
setLanding_page(relatedLanding_page2);
}
const relatedLanding_page3 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const TrackingEvent3 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TrackingEvent3?.setLanding_page)
{
await
TrackingEvent3.
setLanding_page(relatedLanding_page3);
}
const relatedLanding_page4 = await LandingPages.findOne({
offset: Math.floor(Math.random() * (await LandingPages.count())),
});
const TrackingEvent4 = await TrackingEvents.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (TrackingEvent4?.setLanding_page)
{
await
TrackingEvent4.
setLanding_page(relatedLanding_page4);
}
}
async function associateAssetWithOwner_user() {
const relatedOwner_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Asset0 = await Assets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Asset0?.setOwner_user)
{
await
Asset0.
setOwner_user(relatedOwner_user0);
}
const relatedOwner_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Asset1 = await Assets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Asset1?.setOwner_user)
{
await
Asset1.
setOwner_user(relatedOwner_user1);
}
const relatedOwner_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Asset2 = await Assets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Asset2?.setOwner_user)
{
await
Asset2.
setOwner_user(relatedOwner_user2);
}
const relatedOwner_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Asset3 = await Assets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Asset3?.setOwner_user)
{
await
Asset3.
setOwner_user(relatedOwner_user3);
}
const relatedOwner_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Asset4 = await Assets.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Asset4?.setOwner_user)
{
await
Asset4.
setOwner_user(relatedOwner_user4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await LandingPages.bulkCreate(LandingPagesData);
await LandingSections.bulkCreate(LandingSectionsData);
await Services.bulkCreate(ServicesData);
await Leads.bulkCreate(LeadsData);
await LeadAttachments.bulkCreate(LeadAttachmentsData);
await Conversations.bulkCreate(ConversationsData);
await ConversationMessages.bulkCreate(ConversationMessagesData);
await Campaigns.bulkCreate(CampaignsData);
await TrackingEvents.bulkCreate(TrackingEventsData);
await Assets.bulkCreate(AssetsData);
await Integrations.bulkCreate(IntegrationsData);
await Promise.all([
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateLandingSectionWithLanding_page(),
await associateLeadWithLanding_page(),
await associateLeadWithService(),
await associateLeadWithAssigned_to(),
// Similar logic for "relation_many"
await associateLeadAttachmentWithLead(),
await associateConversationWithLead(),
// Similar logic for "relation_many"
await associateConversationMessageWithConversation(),
await associateConversationMessageWithAgent_user(),
// Similar logic for "relation_many"
await associateTrackingEventWithCampaign(),
await associateTrackingEventWithLanding_page(),
await associateAssetWithOwner_user(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('landing_pages', null, {});
await queryInterface.bulkDelete('landing_sections', null, {});
await queryInterface.bulkDelete('services', null, {});
await queryInterface.bulkDelete('leads', null, {});
await queryInterface.bulkDelete('lead_attachments', null, {});
await queryInterface.bulkDelete('conversations', null, {});
await queryInterface.bulkDelete('conversation_messages', null, {});
await queryInterface.bulkDelete('campaigns', null, {});
await queryInterface.bulkDelete('tracking_events', null, {});
await queryInterface.bulkDelete('assets', null, {});
await queryInterface.bulkDelete('integrations', null, {});
},
};