38630-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-19 23:45:10 +00:00

7024 lines
116 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const SiteSettings = db.site_settings;
const ContactLocations = db.contact_locations;
const SocialLinks = db.social_links;
const HeroSlides = db.hero_slides;
const StoneCategories = db.stone_categories;
const StoneColors = db.stone_colors;
const Finishes = db.finishes;
const Applications = db.applications;
const Stones = db.stones;
const StoneVariants = db.stone_variants;
const Stone3dAssets = db.stone_3d_assets;
const Services = db.services;
const Technologies = db.technologies;
const ServiceTechnologies = db.service_technologies;
const Projects = db.projects;
const ProjectMedia = db.project_media;
const TeamMembers = db.team_members;
const BlogCategories = db.blog_categories;
const BlogPosts = db.blog_posts;
const LeadRequests = db.lead_requests;
const QuoteItems = db.quote_items;
const Inquiries = db.inquiries;
const SeoPages = db.seo_pages;
const MediaLibrary = db.media_library;
const SiteSettingsData = [
{
"site_name_ar": "Alan Turing",
"site_tagline_ar": "Alan Turing",
// type code here for "images" field
// type code here for "images" field
"primary_font": "Alan Turing",
"direction": "rtl",
"primary_color_hex": "Marie Curie",
"accent_color_hex": "Alan Turing",
"seo_default_title_ar": "Grace Hopper",
"seo_default_description_ar": "Grace Hopper",
// type code here for "files" field
},
{
"site_name_ar": "Alan Turing",
"site_tagline_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "images" field
"primary_font": "Marie Curie",
"direction": "ltr",
"primary_color_hex": "Alan Turing",
"accent_color_hex": "Ada Lovelace",
"seo_default_title_ar": "Marie Curie",
"seo_default_description_ar": "Alan Turing",
// type code here for "files" field
},
{
"site_name_ar": "Marie Curie",
"site_tagline_ar": "Alan Turing",
// type code here for "images" field
// type code here for "images" field
"primary_font": "Alan Turing",
"direction": "ltr",
"primary_color_hex": "Ada Lovelace",
"accent_color_hex": "Ada Lovelace",
"seo_default_title_ar": "Ada Lovelace",
"seo_default_description_ar": "Marie Curie",
// type code here for "files" field
},
];
const ContactLocationsData = [
{
"name_ar": "Alan Turing",
"address_ar": "Marie Curie",
"phone": "Grace Hopper",
"email": "Marie Curie",
"google_maps_url": "Grace Hopper",
"latitude": 2.04,
"longitude": 5.36,
"is_primary": true,
},
{
"name_ar": "Ada Lovelace",
"address_ar": "Ada Lovelace",
"phone": "Ada Lovelace",
"email": "Marie Curie",
"google_maps_url": "Ada Lovelace",
"latitude": 2.01,
"longitude": 8.67,
"is_primary": true,
},
{
"name_ar": "Marie Curie",
"address_ar": "Alan Turing",
"phone": "Alan Turing",
"email": "Grace Hopper",
"google_maps_url": "Ada Lovelace",
"latitude": 3.14,
"longitude": 4.97,
"is_primary": false,
},
];
const SocialLinksData = [
{
"platform": "instagram",
"url": "Grace Hopper",
"label_ar": "Alan Turing",
"sort_order": 9,
"is_active": true,
},
{
"platform": "pinterest",
"url": "Ada Lovelace",
"label_ar": "Grace Hopper",
"sort_order": 7,
"is_active": false,
},
{
"platform": "pinterest",
"url": "Ada Lovelace",
"label_ar": "Grace Hopper",
"sort_order": 1,
"is_active": true,
},
];
const HeroSlidesData = [
{
"headline_ar": "Alan Turing",
"subheadline_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"cta_type": "products",
"cta_label_ar": "Ada Lovelace",
"cta_url": "Alan Turing",
"sort_order": 4,
"is_active": true,
},
{
"headline_ar": "Grace Hopper",
"subheadline_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"cta_type": "products",
"cta_label_ar": "Alan Turing",
"cta_url": "Grace Hopper",
"sort_order": 7,
"is_active": true,
},
{
"headline_ar": "Ada Lovelace",
"subheadline_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"cta_type": "services",
"cta_label_ar": "Marie Curie",
"cta_url": "Marie Curie",
"sort_order": 8,
"is_active": true,
},
];
const StoneCategoriesData = [
{
"name_ar": "Ada Lovelace",
"slug": "Marie Curie",
"description_ar": "Alan Turing",
// type code here for "images" field
"sort_order": 5,
"is_active": false,
"category_type": "limestone",
},
{
"name_ar": "Alan Turing",
"slug": "Ada Lovelace",
"description_ar": "Alan Turing",
// type code here for "images" field
"sort_order": 3,
"is_active": true,
"category_type": "limestone",
},
{
"name_ar": "Ada Lovelace",
"slug": "Marie Curie",
"description_ar": "Marie Curie",
// type code here for "images" field
"sort_order": 2,
"is_active": false,
"category_type": "limestone",
},
];
const StoneColorsData = [
{
"name_ar": "Ada Lovelace",
"hex": "Alan Turing",
// type code here for "images" field
"sort_order": 1,
"is_active": true,
},
{
"name_ar": "Ada Lovelace",
"hex": "Ada Lovelace",
// type code here for "images" field
"sort_order": 5,
"is_active": true,
},
{
"name_ar": "Alan Turing",
"hex": "Ada Lovelace",
// type code here for "images" field
"sort_order": 5,
"is_active": false,
},
];
const FinishesData = [
{
"name_ar": "Marie Curie",
"description_ar": "Marie Curie",
// type code here for "images" field
"is_active": true,
},
{
"name_ar": "Ada Lovelace",
"description_ar": "Alan Turing",
// type code here for "images" field
"is_active": true,
},
{
"name_ar": "Grace Hopper",
"description_ar": "Grace Hopper",
// type code here for "images" field
"is_active": true,
},
];
const ApplicationsData = [
{
"name_ar": "Ada Lovelace",
"application_scope": "interior",
"description_ar": "Grace Hopper",
"is_active": true,
},
{
"name_ar": "Ada Lovelace",
"application_scope": "exterior",
"description_ar": "Alan Turing",
"is_active": true,
},
{
"name_ar": "Marie Curie",
"application_scope": "hospitality",
"description_ar": "Alan Turing",
"is_active": false,
},
];
const StonesData = [
{
"name_ar": "Alan Turing",
"slug": "Alan Turing",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"short_description_ar": "Grace Hopper",
"description_ar": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
"density": 3.74,
"water_absorption": 7.0,
"compressive_strength": 6.94,
"flexural_strength": 3.5,
"origin_type": "mixed",
"origin_country": "Alan Turing",
"is_featured": true,
"is_active": false,
},
{
"name_ar": "Alan Turing",
"slug": "Grace Hopper",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"short_description_ar": "Alan Turing",
"description_ar": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
"density": 0.78,
"water_absorption": 9.58,
"compressive_strength": 2.83,
"flexural_strength": 1.02,
"origin_type": "mixed",
"origin_country": "Grace Hopper",
"is_featured": false,
"is_active": false,
},
{
"name_ar": "Grace Hopper",
"slug": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"short_description_ar": "Ada Lovelace",
"description_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"density": 8.33,
"water_absorption": 2.87,
"compressive_strength": 3.69,
"flexural_strength": 9.36,
"origin_type": "local",
"origin_country": "Grace Hopper",
"is_featured": false,
"is_active": false,
},
];
const StoneVariantsData = [
{
// type code here for "relation_one" field
"variant_type": "custom",
"sku": "Marie Curie",
"length_mm": 2.43,
"width_mm": 6.12,
"thickness_mm": 1.46,
"weight_kg": 8.38,
"availability_status": "in_stock",
"base_price": 8.91,
"price_note_ar": "Marie Curie",
// type code here for "images" field
"is_active": false,
},
{
// type code here for "relation_one" field
"variant_type": "tile",
"sku": "Alan Turing",
"length_mm": 1.92,
"width_mm": 7.58,
"thickness_mm": 0.68,
"weight_kg": 2.47,
"availability_status": "made_to_order",
"base_price": 9.62,
"price_note_ar": "Alan Turing",
// type code here for "images" field
"is_active": true,
},
{
// type code here for "relation_one" field
"variant_type": "countertop",
"sku": "Grace Hopper",
"length_mm": 7.34,
"width_mm": 9.94,
"thickness_mm": 9.33,
"weight_kg": 2.22,
"availability_status": "in_stock",
"base_price": 3.64,
"price_note_ar": "Grace Hopper",
// type code here for "images" field
"is_active": true,
},
];
const Stone3dAssetsData = [
{
// type code here for "relation_one" field
"asset_type": "other",
// type code here for "files" field
// type code here for "images" field
"viewer_hint_ar": "Alan Turing",
"is_active": false,
},
{
// type code here for "relation_one" field
"asset_type": "other",
// type code here for "files" field
// type code here for "images" field
"viewer_hint_ar": "Marie Curie",
"is_active": true,
},
{
// type code here for "relation_one" field
"asset_type": "glb",
// type code here for "files" field
// type code here for "images" field
"viewer_hint_ar": "Grace Hopper",
"is_active": true,
},
];
const ServicesData = [
{
"name_ar": "Alan Turing",
"slug": "Ada Lovelace",
"service_type": "cnc_cutting",
"summary_ar": "Alan Turing",
"description_ar": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
"sort_order": 1,
"is_featured": false,
"is_active": true,
},
{
"name_ar": "Grace Hopper",
"slug": "Grace Hopper",
"service_type": "waterjet_cutting",
"summary_ar": "Ada Lovelace",
"description_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"sort_order": 9,
"is_featured": true,
"is_active": false,
},
{
"name_ar": "Ada Lovelace",
"slug": "Marie Curie",
"service_type": "installation_support",
"summary_ar": "Alan Turing",
"description_ar": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
"sort_order": 2,
"is_featured": true,
"is_active": false,
},
];
const TechnologiesData = [
{
"name_ar": "Ada Lovelace",
"technology_type": "polishing_line",
"description_ar": "Ada Lovelace",
// type code here for "images" field
"is_active": true,
},
{
"name_ar": "Marie Curie",
"technology_type": "polishing_line",
"description_ar": "Marie Curie",
// type code here for "images" field
"is_active": true,
},
{
"name_ar": "Marie Curie",
"technology_type": "laser_measurement",
"description_ar": "Grace Hopper",
// type code here for "images" field
"is_active": true,
},
];
const ServiceTechnologiesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note_ar": "Ada Lovelace",
"sort_order": 8,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note_ar": "Ada Lovelace",
"sort_order": 1,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note_ar": "Alan Turing",
"sort_order": 3,
},
];
const ProjectsData = [
{
"name_ar": "Marie Curie",
"slug": "Alan Turing",
"project_scope": "exterior",
"location_ar": "Grace Hopper",
"summary_ar": "Ada Lovelace",
"description_ar": "Alan Turing",
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "images" field
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
"started_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"is_featured": true,
"is_published": true,
},
{
"name_ar": "Marie Curie",
"slug": "Ada Lovelace",
"project_scope": "residential",
"location_ar": "Alan Turing",
"summary_ar": "Alan Turing",
"description_ar": "Grace Hopper",
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "images" field
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
"started_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"is_featured": true,
"is_published": true,
},
{
"name_ar": "Grace Hopper",
"slug": "Alan Turing",
"project_scope": "interior",
"location_ar": "Alan Turing",
"summary_ar": "Alan Turing",
"description_ar": "Grace Hopper",
// type code here for "relation_many" field
// type code here for "relation_many" field
// type code here for "images" field
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
"started_at": new Date(Date.now()),
"completed_at": new Date(Date.now()),
"is_featured": false,
"is_published": true,
},
];
const ProjectMediaData = [
{
// type code here for "relation_one" field
"media_kind": "video",
// type code here for "images" field
// type code here for "files" field
"media_role": "process",
"caption_ar": "Marie Curie",
"sort_order": 2,
"is_active": true,
},
{
// type code here for "relation_one" field
"media_kind": "video",
// type code here for "images" field
// type code here for "files" field
"media_role": "process",
"caption_ar": "Grace Hopper",
"sort_order": 5,
"is_active": true,
},
{
// type code here for "relation_one" field
"media_kind": "image",
// type code here for "images" field
// type code here for "files" field
"media_role": "before",
"caption_ar": "Ada Lovelace",
"sort_order": 7,
"is_active": false,
},
];
const TeamMembersData = [
{
"name_ar": "Alan Turing",
"job_title_ar": "Alan Turing",
"bio_ar": "Marie Curie",
// type code here for "images" field
"email": "Grace Hopper",
"phone": "Grace Hopper",
"sort_order": 4,
"is_active": false,
},
{
"name_ar": "Ada Lovelace",
"job_title_ar": "Marie Curie",
"bio_ar": "Grace Hopper",
// type code here for "images" field
"email": "Ada Lovelace",
"phone": "Grace Hopper",
"sort_order": 8,
"is_active": true,
},
{
"name_ar": "Alan Turing",
"job_title_ar": "Marie Curie",
"bio_ar": "Ada Lovelace",
// type code here for "images" field
"email": "Marie Curie",
"phone": "Grace Hopper",
"sort_order": 5,
"is_active": true,
},
];
const BlogCategoriesData = [
{
"name_ar": "Marie Curie",
"slug": "Marie Curie",
"description_ar": "Alan Turing",
"sort_order": 5,
"is_active": false,
},
{
"name_ar": "Grace Hopper",
"slug": "Alan Turing",
"description_ar": "Ada Lovelace",
"sort_order": 1,
"is_active": false,
},
{
"name_ar": "Alan Turing",
"slug": "Alan Turing",
"description_ar": "Marie Curie",
"sort_order": 6,
"is_active": true,
},
];
const BlogPostsData = [
{
"title_ar": "Marie Curie",
"slug": "Alan Turing",
// type code here for "relation_one" field
// type code here for "relation_one" field
"excerpt_ar": "Ada Lovelace",
"content_ar": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"publish_status": "scheduled",
"published_at": new Date(Date.now()),
"is_featured": true,
},
{
"title_ar": "Marie Curie",
"slug": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
"excerpt_ar": "Alan Turing",
"content_ar": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"publish_status": "draft",
"published_at": new Date(Date.now()),
"is_featured": false,
},
{
"title_ar": "Alan Turing",
"slug": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
"excerpt_ar": "Ada Lovelace",
"content_ar": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_many" field
"publish_status": "draft",
"published_at": new Date(Date.now()),
"is_featured": true,
},
];
const LeadRequestsData = [
{
"request_type": "callback",
"full_name": "Grace Hopper",
"company_name": "Alan Turing",
"email": "Marie Curie",
"phone": "Alan Turing",
"customer_type": "other",
"message_ar": "Grace Hopper",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
"lead_status": "closed",
// type code here for "relation_one" field
"preferred_contact_time": new Date(Date.now()),
"last_contacted_at": new Date(Date.now()),
"internal_notes": "Grace Hopper",
},
{
"request_type": "custom_order",
"full_name": "Grace Hopper",
"company_name": "Ada Lovelace",
"email": "Ada Lovelace",
"phone": "Grace Hopper",
"customer_type": "contractor",
"message_ar": "Marie Curie",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
"lead_status": "closed",
// type code here for "relation_one" field
"preferred_contact_time": new Date(Date.now()),
"last_contacted_at": new Date(Date.now()),
"internal_notes": "Marie Curie",
},
{
"request_type": "quote",
"full_name": "Alan Turing",
"company_name": "Ada Lovelace",
"email": "Marie Curie",
"phone": "Ada Lovelace",
"customer_type": "architect",
"message_ar": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "files" field
"lead_status": "won",
// type code here for "relation_one" field
"preferred_contact_time": new Date(Date.now()),
"last_contacted_at": new Date(Date.now()),
"internal_notes": "Alan Turing",
},
];
const QuoteItemsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"item_description_ar": "Grace Hopper",
"quantity": 0.73,
"unit": "sqm",
"unit_price": 6.08,
"discount_amount": 2.31,
"tax_amount": 8.22,
"line_total": 2.18,
"sort_order": 2,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"item_description_ar": "Grace Hopper",
"quantity": 3.75,
"unit": "set",
"unit_price": 0.18,
"discount_amount": 9.73,
"tax_amount": 5.49,
"line_total": 9.94,
"sort_order": 8,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"item_description_ar": "Ada Lovelace",
"quantity": 8.2,
"unit": "set",
"unit_price": 6.33,
"discount_amount": 1.94,
"tax_amount": 4.48,
"line_total": 5.52,
"sort_order": 7,
},
];
const InquiriesData = [
{
"full_name": "Ada Lovelace",
"email": "Ada Lovelace",
"phone": "Alan Turing",
"subject_ar": "Ada Lovelace",
"message_ar": "Marie Curie",
// type code here for "relation_one" field
"status": "replied",
// type code here for "relation_one" field
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
},
{
"full_name": "Grace Hopper",
"email": "Ada Lovelace",
"phone": "Marie Curie",
"subject_ar": "Grace Hopper",
"message_ar": "Alan Turing",
// type code here for "relation_one" field
"status": "new",
// type code here for "relation_one" field
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
},
{
"full_name": "Marie Curie",
"email": "Alan Turing",
"phone": "Ada Lovelace",
"subject_ar": "Ada Lovelace",
"message_ar": "Alan Turing",
// type code here for "relation_one" field
"status": "replied",
// type code here for "relation_one" field
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
},
];
const SeoPagesData = [
{
"page_key": "services",
"title_ar": "Alan Turing",
"description_ar": "Ada Lovelace",
"canonical_url": "Alan Turing",
// type code here for "files" field
"indexable": true,
},
{
"page_key": "contact",
"title_ar": "Marie Curie",
"description_ar": "Marie Curie",
"canonical_url": "Alan Turing",
// type code here for "files" field
"indexable": false,
},
{
"page_key": "about",
"title_ar": "Grace Hopper",
"description_ar": "Grace Hopper",
"canonical_url": "Grace Hopper",
// type code here for "files" field
"indexable": true,
},
];
const MediaLibraryData = [
{
"media_type": "document",
"title_ar": "Alan Turing",
"alt_text_ar": "Marie Curie",
// type code here for "images" field
// type code here for "files" field
"source_note_ar": "Ada Lovelace",
"is_public": true,
},
{
"media_type": "video",
"title_ar": "Alan Turing",
"alt_text_ar": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"source_note_ar": "Grace Hopper",
"is_public": false,
},
{
"media_type": "image",
"title_ar": "Marie Curie",
"alt_text_ar": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
"source_note_ar": "Marie Curie",
"is_public": true,
},
];
// Similar logic for "relation_many"
async function associateStoneWithCategory() {
const relatedCategory0 = await StoneCategories.findOne({
offset: Math.floor(Math.random() * (await StoneCategories.count())),
});
const Stone0 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Stone0?.setCategory)
{
await
Stone0.
setCategory(relatedCategory0);
}
const relatedCategory1 = await StoneCategories.findOne({
offset: Math.floor(Math.random() * (await StoneCategories.count())),
});
const Stone1 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Stone1?.setCategory)
{
await
Stone1.
setCategory(relatedCategory1);
}
const relatedCategory2 = await StoneCategories.findOne({
offset: Math.floor(Math.random() * (await StoneCategories.count())),
});
const Stone2 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Stone2?.setCategory)
{
await
Stone2.
setCategory(relatedCategory2);
}
}
async function associateStoneWithColor() {
const relatedColor0 = await StoneColors.findOne({
offset: Math.floor(Math.random() * (await StoneColors.count())),
});
const Stone0 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Stone0?.setColor)
{
await
Stone0.
setColor(relatedColor0);
}
const relatedColor1 = await StoneColors.findOne({
offset: Math.floor(Math.random() * (await StoneColors.count())),
});
const Stone1 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Stone1?.setColor)
{
await
Stone1.
setColor(relatedColor1);
}
const relatedColor2 = await StoneColors.findOne({
offset: Math.floor(Math.random() * (await StoneColors.count())),
});
const Stone2 = await Stones.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Stone2?.setColor)
{
await
Stone2.
setColor(relatedColor2);
}
}
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateStoneVariantWithStone() {
const relatedStone0 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const StoneVariant0 = await StoneVariants.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StoneVariant0?.setStone)
{
await
StoneVariant0.
setStone(relatedStone0);
}
const relatedStone1 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const StoneVariant1 = await StoneVariants.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StoneVariant1?.setStone)
{
await
StoneVariant1.
setStone(relatedStone1);
}
const relatedStone2 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const StoneVariant2 = await StoneVariants.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StoneVariant2?.setStone)
{
await
StoneVariant2.
setStone(relatedStone2);
}
}
async function associateStone3dAssetWithStone() {
const relatedStone0 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const Stone3dAsset0 = await Stone3dAssets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Stone3dAsset0?.setStone)
{
await
Stone3dAsset0.
setStone(relatedStone0);
}
const relatedStone1 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const Stone3dAsset1 = await Stone3dAssets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Stone3dAsset1?.setStone)
{
await
Stone3dAsset1.
setStone(relatedStone1);
}
const relatedStone2 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const Stone3dAsset2 = await Stone3dAssets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Stone3dAsset2?.setStone)
{
await
Stone3dAsset2.
setStone(relatedStone2);
}
}
async function associateServiceTechnologyWithService() {
const relatedService0 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const ServiceTechnology0 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ServiceTechnology0?.setService)
{
await
ServiceTechnology0.
setService(relatedService0);
}
const relatedService1 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const ServiceTechnology1 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ServiceTechnology1?.setService)
{
await
ServiceTechnology1.
setService(relatedService1);
}
const relatedService2 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const ServiceTechnology2 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ServiceTechnology2?.setService)
{
await
ServiceTechnology2.
setService(relatedService2);
}
}
async function associateServiceTechnologyWithTechnology() {
const relatedTechnology0 = await Technologies.findOne({
offset: Math.floor(Math.random() * (await Technologies.count())),
});
const ServiceTechnology0 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ServiceTechnology0?.setTechnology)
{
await
ServiceTechnology0.
setTechnology(relatedTechnology0);
}
const relatedTechnology1 = await Technologies.findOne({
offset: Math.floor(Math.random() * (await Technologies.count())),
});
const ServiceTechnology1 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ServiceTechnology1?.setTechnology)
{
await
ServiceTechnology1.
setTechnology(relatedTechnology1);
}
const relatedTechnology2 = await Technologies.findOne({
offset: Math.floor(Math.random() * (await Technologies.count())),
});
const ServiceTechnology2 = await ServiceTechnologies.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ServiceTechnology2?.setTechnology)
{
await
ServiceTechnology2.
setTechnology(relatedTechnology2);
}
}
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateProjectMediaWithProject() {
const relatedProject0 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const ProjectMedia0 = await ProjectMedia.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ProjectMedia0?.setProject)
{
await
ProjectMedia0.
setProject(relatedProject0);
}
const relatedProject1 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const ProjectMedia1 = await ProjectMedia.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ProjectMedia1?.setProject)
{
await
ProjectMedia1.
setProject(relatedProject1);
}
const relatedProject2 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const ProjectMedia2 = await ProjectMedia.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ProjectMedia2?.setProject)
{
await
ProjectMedia2.
setProject(relatedProject2);
}
}
async function associateBlogPostWithCategory() {
const relatedCategory0 = await BlogCategories.findOne({
offset: Math.floor(Math.random() * (await BlogCategories.count())),
});
const BlogPost0 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (BlogPost0?.setCategory)
{
await
BlogPost0.
setCategory(relatedCategory0);
}
const relatedCategory1 = await BlogCategories.findOne({
offset: Math.floor(Math.random() * (await BlogCategories.count())),
});
const BlogPost1 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (BlogPost1?.setCategory)
{
await
BlogPost1.
setCategory(relatedCategory1);
}
const relatedCategory2 = await BlogCategories.findOne({
offset: Math.floor(Math.random() * (await BlogCategories.count())),
});
const BlogPost2 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (BlogPost2?.setCategory)
{
await
BlogPost2.
setCategory(relatedCategory2);
}
}
async function associateBlogPostWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BlogPost0 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (BlogPost0?.setAuthor)
{
await
BlogPost0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BlogPost1 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (BlogPost1?.setAuthor)
{
await
BlogPost1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const BlogPost2 = await BlogPosts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (BlogPost2?.setAuthor)
{
await
BlogPost2.
setAuthor(relatedAuthor2);
}
}
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateLeadRequestWithInterested_stone() {
const relatedInterested_stone0 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const LeadRequest0 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LeadRequest0?.setInterested_stone)
{
await
LeadRequest0.
setInterested_stone(relatedInterested_stone0);
}
const relatedInterested_stone1 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const LeadRequest1 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LeadRequest1?.setInterested_stone)
{
await
LeadRequest1.
setInterested_stone(relatedInterested_stone1);
}
const relatedInterested_stone2 = await Stones.findOne({
offset: Math.floor(Math.random() * (await Stones.count())),
});
const LeadRequest2 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LeadRequest2?.setInterested_stone)
{
await
LeadRequest2.
setInterested_stone(relatedInterested_stone2);
}
}
async function associateLeadRequestWithInterested_service() {
const relatedInterested_service0 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const LeadRequest0 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LeadRequest0?.setInterested_service)
{
await
LeadRequest0.
setInterested_service(relatedInterested_service0);
}
const relatedInterested_service1 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const LeadRequest1 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LeadRequest1?.setInterested_service)
{
await
LeadRequest1.
setInterested_service(relatedInterested_service1);
}
const relatedInterested_service2 = await Services.findOne({
offset: Math.floor(Math.random() * (await Services.count())),
});
const LeadRequest2 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LeadRequest2?.setInterested_service)
{
await
LeadRequest2.
setInterested_service(relatedInterested_service2);
}
}
async function associateLeadRequestWithRelated_project() {
const relatedRelated_project0 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const LeadRequest0 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LeadRequest0?.setRelated_project)
{
await
LeadRequest0.
setRelated_project(relatedRelated_project0);
}
const relatedRelated_project1 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const LeadRequest1 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LeadRequest1?.setRelated_project)
{
await
LeadRequest1.
setRelated_project(relatedRelated_project1);
}
const relatedRelated_project2 = await Projects.findOne({
offset: Math.floor(Math.random() * (await Projects.count())),
});
const LeadRequest2 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LeadRequest2?.setRelated_project)
{
await
LeadRequest2.
setRelated_project(relatedRelated_project2);
}
}
async function associateLeadRequestWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LeadRequest0 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LeadRequest0?.setAssigned_to)
{
await
LeadRequest0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LeadRequest1 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LeadRequest1?.setAssigned_to)
{
await
LeadRequest1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LeadRequest2 = await LeadRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LeadRequest2?.setAssigned_to)
{
await
LeadRequest2.
setAssigned_to(relatedAssigned_to2);
}
}
async function associateQuoteItemWithLead_request() {
const relatedLead_request0 = await LeadRequests.findOne({
offset: Math.floor(Math.random() * (await LeadRequests.count())),
});
const QuoteItem0 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (QuoteItem0?.setLead_request)
{
await
QuoteItem0.
setLead_request(relatedLead_request0);
}
const relatedLead_request1 = await LeadRequests.findOne({
offset: Math.floor(Math.random() * (await LeadRequests.count())),
});
const QuoteItem1 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (QuoteItem1?.setLead_request)
{
await
QuoteItem1.
setLead_request(relatedLead_request1);
}
const relatedLead_request2 = await LeadRequests.findOne({
offset: Math.floor(Math.random() * (await LeadRequests.count())),
});
const QuoteItem2 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (QuoteItem2?.setLead_request)
{
await
QuoteItem2.
setLead_request(relatedLead_request2);
}
}
async function associateQuoteItemWithStone_variant() {
const relatedStone_variant0 = await StoneVariants.findOne({
offset: Math.floor(Math.random() * (await StoneVariants.count())),
});
const QuoteItem0 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (QuoteItem0?.setStone_variant)
{
await
QuoteItem0.
setStone_variant(relatedStone_variant0);
}
const relatedStone_variant1 = await StoneVariants.findOne({
offset: Math.floor(Math.random() * (await StoneVariants.count())),
});
const QuoteItem1 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (QuoteItem1?.setStone_variant)
{
await
QuoteItem1.
setStone_variant(relatedStone_variant1);
}
const relatedStone_variant2 = await StoneVariants.findOne({
offset: Math.floor(Math.random() * (await StoneVariants.count())),
});
const QuoteItem2 = await QuoteItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (QuoteItem2?.setStone_variant)
{
await
QuoteItem2.
setStone_variant(relatedStone_variant2);
}
}
async function associateInquiryWithLocation() {
const relatedLocation0 = await ContactLocations.findOne({
offset: Math.floor(Math.random() * (await ContactLocations.count())),
});
const Inquiry0 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Inquiry0?.setLocation)
{
await
Inquiry0.
setLocation(relatedLocation0);
}
const relatedLocation1 = await ContactLocations.findOne({
offset: Math.floor(Math.random() * (await ContactLocations.count())),
});
const Inquiry1 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Inquiry1?.setLocation)
{
await
Inquiry1.
setLocation(relatedLocation1);
}
const relatedLocation2 = await ContactLocations.findOne({
offset: Math.floor(Math.random() * (await ContactLocations.count())),
});
const Inquiry2 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Inquiry2?.setLocation)
{
await
Inquiry2.
setLocation(relatedLocation2);
}
}
async function associateInquiryWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry0 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Inquiry0?.setAssigned_to)
{
await
Inquiry0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry1 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Inquiry1?.setAssigned_to)
{
await
Inquiry1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry2 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Inquiry2?.setAssigned_to)
{
await
Inquiry2.
setAssigned_to(relatedAssigned_to2);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await SiteSettings.bulkCreate(SiteSettingsData);
await ContactLocations.bulkCreate(ContactLocationsData);
await SocialLinks.bulkCreate(SocialLinksData);
await HeroSlides.bulkCreate(HeroSlidesData);
await StoneCategories.bulkCreate(StoneCategoriesData);
await StoneColors.bulkCreate(StoneColorsData);
await Finishes.bulkCreate(FinishesData);
await Applications.bulkCreate(ApplicationsData);
await Stones.bulkCreate(StonesData);
await StoneVariants.bulkCreate(StoneVariantsData);
await Stone3dAssets.bulkCreate(Stone3dAssetsData);
await Services.bulkCreate(ServicesData);
await Technologies.bulkCreate(TechnologiesData);
await ServiceTechnologies.bulkCreate(ServiceTechnologiesData);
await Projects.bulkCreate(ProjectsData);
await ProjectMedia.bulkCreate(ProjectMediaData);
await TeamMembers.bulkCreate(TeamMembersData);
await BlogCategories.bulkCreate(BlogCategoriesData);
await BlogPosts.bulkCreate(BlogPostsData);
await LeadRequests.bulkCreate(LeadRequestsData);
await QuoteItems.bulkCreate(QuoteItemsData);
await Inquiries.bulkCreate(InquiriesData);
await SeoPages.bulkCreate(SeoPagesData);
await MediaLibrary.bulkCreate(MediaLibraryData);
await Promise.all([
// Similar logic for "relation_many"
await associateStoneWithCategory(),
await associateStoneWithColor(),
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateStoneVariantWithStone(),
await associateStone3dAssetWithStone(),
await associateServiceTechnologyWithService(),
await associateServiceTechnologyWithTechnology(),
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateProjectMediaWithProject(),
await associateBlogPostWithCategory(),
await associateBlogPostWithAuthor(),
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateLeadRequestWithInterested_stone(),
await associateLeadRequestWithInterested_service(),
await associateLeadRequestWithRelated_project(),
await associateLeadRequestWithAssigned_to(),
await associateQuoteItemWithLead_request(),
await associateQuoteItemWithStone_variant(),
await associateInquiryWithLocation(),
await associateInquiryWithAssigned_to(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('site_settings', null, {});
await queryInterface.bulkDelete('contact_locations', null, {});
await queryInterface.bulkDelete('social_links', null, {});
await queryInterface.bulkDelete('hero_slides', null, {});
await queryInterface.bulkDelete('stone_categories', null, {});
await queryInterface.bulkDelete('stone_colors', null, {});
await queryInterface.bulkDelete('finishes', null, {});
await queryInterface.bulkDelete('applications', null, {});
await queryInterface.bulkDelete('stones', null, {});
await queryInterface.bulkDelete('stone_variants', null, {});
await queryInterface.bulkDelete('stone_3d_assets', null, {});
await queryInterface.bulkDelete('services', null, {});
await queryInterface.bulkDelete('technologies', null, {});
await queryInterface.bulkDelete('service_technologies', null, {});
await queryInterface.bulkDelete('projects', null, {});
await queryInterface.bulkDelete('project_media', null, {});
await queryInterface.bulkDelete('team_members', null, {});
await queryInterface.bulkDelete('blog_categories', null, {});
await queryInterface.bulkDelete('blog_posts', null, {});
await queryInterface.bulkDelete('lead_requests', null, {});
await queryInterface.bulkDelete('quote_items', null, {});
await queryInterface.bulkDelete('inquiries', null, {});
await queryInterface.bulkDelete('seo_pages', null, {});
await queryInterface.bulkDelete('media_library', null, {});
},
};