38185-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-04 13:29:57 +00:00

8873 lines
166 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Genres = db.genres;
const People = db.people;
const Studios = db.studios;
const Titles = db.titles;
const TitlePeople = db.title_people;
const Seasons = db.seasons;
const Episodes = db.episodes;
const VideoSources = db.video_sources;
const Subscriptions = db.subscriptions;
const UserSubscriptions = db.user_subscriptions;
const Payments = db.payments;
const WatchHistory = db.watch_history;
const Favorites = db.favorites;
const Reviews = db.reviews;
const Ads = db.ads;
const AdImpressions = db.ad_impressions;
const Devices = db.devices;
const SupportTickets = db.support_tickets;
const GenresData = [
{
"name": "Action",
"slug": "action",
"description": "Fast paced stories with stunts and high stakes.",
// type code here for "images" field
"is_active": true,
},
{
"name": "Drama",
"slug": "drama",
"description": "Character driven narratives with emotional depth.",
// type code here for "images" field
"is_active": true,
},
{
"name": "Comedy",
"slug": "comedy",
"description": "Lighthearted storytelling designed to entertain.",
// type code here for "images" field
"is_active": true,
},
{
"name": "Sci Fi",
"slug": "sci-fi",
"description": "Futuristic concepts, science, and imaginative worlds.",
// type code here for "images" field
"is_active": true,
},
{
"name": "Thriller",
"slug": "thriller",
"description": "Tense plots with suspense and unexpected turns.",
// type code here for "images" field
"is_active": true,
},
];
const PeopleData = [
{
"full_name": "Layla Mansour",
"native_name": "ليلى منصور",
"person_type": "producer",
"bio": "Performer known for dramatic lead roles across film and television.",
"birth_date": new Date('1990-04-12T00:00:00Z'),
"country": "EG",
// type code here for "images" field
"is_active": true,
},
{
"full_name": "Samir Al Hakim",
"native_name": "سمير الحكيم",
"person_type": "other",
"bio": "Director focused on grounded stories with strong visual style.",
"birth_date": new Date('1978-09-03T00:00:00Z'),
"country": "SA",
// type code here for "images" field
"is_active": true,
},
{
"full_name": "Rania El Sherif",
"native_name": "رانيا الشريف",
"person_type": "director",
"bio": "Screenwriter specializing in thrillers and investigative dramas.",
"birth_date": new Date('1985-01-20T00:00:00Z'),
"country": "AE",
// type code here for "images" field
"is_active": true,
},
{
"full_name": "Daniel Price",
"native_name": "Daniel Price",
"person_type": "other",
"bio": "Producer with a background in independent cinema and streaming releases.",
"birth_date": new Date('1972-06-18T00:00:00Z'),
"country": "GB",
// type code here for "images" field
"is_active": true,
},
{
"full_name": "Mina Farouk",
"native_name": "مينا فاروق",
"person_type": "director",
"bio": "Composer creating modern scores blending orchestral and electronic elements.",
"birth_date": new Date('1992-11-05T00:00:00Z'),
"country": "US",
// type code here for "images" field
"is_active": true,
},
];
const StudiosData = [
{
"name": "Crescent Pictures",
"slug": "crescent-pictures",
"description": "Regional studio producing premium series and feature films.",
// type code here for "images" field
"website": "https://crescentpics.example",
"country": "SA",
"is_active": true,
},
{
"name": "Nile Stream Works",
"slug": "nile-stream-works",
"description": "Production house focused on digital first entertainment.",
// type code here for "images" field
"website": "https://nilestreamworks.example",
"country": "EG",
"is_active": true,
},
{
"name": "Atlas Media Group",
"slug": "atlas-media-group",
"description": "Studio with a catalog of action and thriller titles.",
// type code here for "images" field
"website": "https://atlasmediagroup.example",
"country": "AE",
"is_active": true,
},
{
"name": "Northbridge Studios",
"slug": "northbridge-studios",
"description": "International co productions for streaming platforms.",
// type code here for "images" field
"website": "https://northbridgestudios.example",
"country": "GB",
"is_active": true,
},
{
"name": "Blue Harbor Entertainment",
"slug": "blue-harbor-entertainment",
"description": "Independent studio developing character driven stories.",
// type code here for "images" field
"website": "https://blueharbor.example",
"country": "US",
"is_active": true,
},
];
const TitlesData = [
{
"content_type": "series",
"title": "Desert Run",
"original_title": "Desert Run",
"slug": "desert-run",
"tagline": "No map. No mercy.",
"synopsis": "A former courier is forced into one last job across the desert while being hunted by rival crews.",
"status": "published",
"maturity_rating": "pg",
"language": "en",
"country_of_origin": "US",
"release_date": new Date('2024-10-11T00:00:00Z'),
"runtime_minutes": 112,
"imdb_rating": 7.3,
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_one" field
// type code here for "relation_many" field
"is_featured": true,
"views_count": 248120,
},
{
"content_type": "series",
"title": "Cairo Nights",
"original_title": "ليالي القاهرة",
"slug": "cairo-nights",
"tagline": "Every secret has a cost.",
"synopsis": "A serialized drama following intertwined lives in a bustling city as ambitions and loyalties collide.",
"status": "archived",
"maturity_rating": "g",
"language": "ar",
"country_of_origin": "EG",
"release_date": new Date('2025-03-02T00:00:00Z'),
"runtime_minutes": 0,
"imdb_rating": 8.1,
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_one" field
// type code here for "relation_many" field
"is_featured": true,
"views_count": 512340,
},
{
"content_type": "series",
"title": "Signal Blackout",
"original_title": "Signal Blackout",
"slug": "signal-blackout",
"tagline": "When the network falls silent.",
"synopsis": "A cyber incident shuts down a city and a small team races to restore communications before panic spreads.",
"status": "draft",
"maturity_rating": "tv_y7",
"language": "en",
"country_of_origin": "GB",
"release_date": new Date('2023-07-21T00:00:00Z'),
"runtime_minutes": 104,
"imdb_rating": 6.9,
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_one" field
// type code here for "relation_many" field
"is_featured": true,
"views_count": 187450,
},
{
"content_type": "movie",
"title": "The Fourth Gate",
"original_title": "The Fourth Gate",
"slug": "the-fourth-gate",
"tagline": "Truth hides behind protocol.",
"synopsis": "A thriller series about an investigative journalist uncovering a hidden network operating in plain sight.",
"status": "published",
"maturity_rating": "tv_14",
"language": "en",
"country_of_origin": "AE",
"release_date": new Date('2026-02-15T00:00:00Z'),
"runtime_minutes": 0,
"imdb_rating": 0,
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_one" field
// type code here for "relation_many" field
"is_featured": true,
"views_count": 0,
},
{
"content_type": "movie",
"title": "Laughing Matters",
"original_title": "Laughing Matters",
"slug": "laughing-matters",
"tagline": "Comedy is serious business.",
"synopsis": "A struggling comic finds unexpected success after a viral set and learns the price of fame.",
"status": "published",
"maturity_rating": "nc_17",
"language": "en",
"country_of_origin": "US",
"release_date": new Date('2021-05-14T00:00:00Z'),
"runtime_minutes": 96,
"imdb_rating": 6.4,
// type code here for "images" field
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_many" field
// type code here for "relation_one" field
// type code here for "relation_many" field
"is_featured": false,
"views_count": 93410,
},
];
const TitlePeopleData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"credit_role": "producer",
"character_name": "N A",
"billing_order": 1,
"is_primary": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"credit_role": "writer",
"character_name": "Maya Reed",
"billing_order": 2,
"is_primary": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"credit_role": "other",
"character_name": "N A",
"billing_order": 1,
"is_primary": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"credit_role": "writer",
"character_name": "N A",
"billing_order": 2,
"is_primary": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"credit_role": "other",
"character_name": "N A",
"billing_order": 1,
"is_primary": true,
},
];
const SeasonsData = [
{
// type code here for "relation_one" field
"season_number": 1,
"name": "Season 1",
"overview": "Introduces the main characters and the central conflict in the neighborhood.",
"release_date": new Date('2025-03-02T00:00:00Z'),
// type code here for "images" field
"status": "draft",
"views_count": 210340,
},
{
// type code here for "relation_one" field
"season_number": 2,
"name": "Season 2",
"overview": "Relationships shift as new rivals enter the scene and stakes rise.",
"release_date": new Date('2026-01-10T00:00:00Z'),
// type code here for "images" field
"status": "draft",
"views_count": 132980,
},
{
// type code here for "relation_one" field
"season_number": 1,
"name": "Season 1",
"overview": "A journalist follows a lead that opens a far reaching conspiracy.",
"release_date": new Date('2026-02-15T00:00:00Z'),
// type code here for "images" field
"status": "archived",
"views_count": 0,
},
{
// type code here for "relation_one" field
"season_number": 3,
"name": "Season 3",
"overview": "A major secret surfaces and the community faces its breaking point.",
"release_date": new Date('2026-09-20T00:00:00Z'),
// type code here for "images" field
"status": "archived",
"views_count": 0,
},
{
// type code here for "relation_one" field
"season_number": 2,
"name": "Season 2",
"overview": "The investigation spreads internationally and alliances fracture.",
"release_date": new Date('2027-03-01T00:00:00Z'),
// type code here for "images" field
"status": "draft",
"views_count": 0,
},
];
const EpisodesData = [
{
// type code here for "relation_one" field
"episode_number": 1,
"title": "First Light",
"overview": "A new opportunity emerges and old debts resurface.",
"air_date": new Date('2025-03-02T00:00:00Z'),
"runtime_minutes": 44,
"status": "draft",
// type code here for "images" field
// type code here for "files" field
"video_stream_url": "https://stream.example.com/hls/cn-s1-e1.m3u8",
"views_count": 80420,
},
{
// type code here for "relation_one" field
"episode_number": 2,
"title": "Crossroads",
"overview": "Two families collide over a deal that should have stayed quiet.",
"air_date": new Date('2025-03-09T00:00:00Z'),
"runtime_minutes": 46,
"status": "published",
// type code here for "images" field
// type code here for "files" field
"video_stream_url": "https://stream.example.com/hls/cn-s1-e2.m3u8",
"views_count": 70210,
},
{
// type code here for "relation_one" field
"episode_number": 1,
"title": "Aftershocks",
"overview": "The aftermath forces new alliances and risky choices.",
"air_date": new Date('2026-01-10T00:00:00Z'),
"runtime_minutes": 45,
"status": "published",
// type code here for "images" field
// type code here for "files" field
"video_stream_url": "https://stream.example.com/hls/cn-s2-e1.m3u8",
"views_count": 61200,
},
{
// type code here for "relation_one" field
"episode_number": 1,
"title": "New Rules",
"overview": "A new leader changes the balance and reveals a hidden plan.",
"air_date": new Date('2026-09-20T00:00:00Z'),
"runtime_minutes": 47,
"status": "draft",
// type code here for "images" field
// type code here for "files" field
"video_stream_url": "https://stream.example.com/hls/cn-s3-e1.m3u8",
"views_count": 0,
},
{
// type code here for "relation_one" field
"episode_number": 2,
"title": "The Price",
"overview": "Consequences hit hard as a secret negotiation unravels.",
"air_date": new Date('2026-09-27T00:00:00Z'),
"runtime_minutes": 46,
"status": "archived",
// type code here for "images" field
// type code here for "files" field
"video_stream_url": "https://stream.example.com/hls/cn-s3-e2.m3u8",
"views_count": 0,
},
];
const VideoSourcesData = [
{
"source_for": "title",
// type code here for "relation_one" field
// type code here for "relation_one" field
"source_type": "hls",
"quality_label": "1080p",
"bitrate_kbps": 4500,
"url": "https://stream.example.com/hls/desert-run-1080.m3u8",
// type code here for "files" field
"drm_enabled": true,
"drm_provider": "widevine",
"is_active": true,
},
{
"source_for": "title",
// type code here for "relation_one" field
// type code here for "relation_one" field
"source_type": "hls",
"quality_label": "720p",
"bitrate_kbps": 2500,
"url": "https://cdn.example.com/videos/desert-run-720p.mp4",
// type code here for "files" field
"drm_enabled": true,
"drm_provider": "none",
"is_active": true,
},
{
"source_for": "title",
// type code here for "relation_one" field
// type code here for "relation_one" field
"source_type": "mp4",
"quality_label": "1080p",
"bitrate_kbps": 4200,
"url": "https://stream.example.com/hls/cn-s1-e1-1080.m3u8",
// type code here for "files" field
"drm_enabled": true,
"drm_provider": "widevine",
"is_active": true,
},
{
"source_for": "title",
// type code here for "relation_one" field
// type code here for "relation_one" field
"source_type": "mp4",
"quality_label": "720p",
"bitrate_kbps": 2600,
"url": "https://stream.example.com/hls/cn-s1-e2-720.m3u8",
// type code here for "files" field
"drm_enabled": true,
"drm_provider": "none",
"is_active": true,
},
{
"source_for": "episode",
// type code here for "relation_one" field
// type code here for "relation_one" field
"source_type": "dash",
"quality_label": "1080p",
"bitrate_kbps": 0,
"url": "https://player.example.com/embed/signal-blackout",
// type code here for "files" field
"drm_enabled": false,
"drm_provider": "none",
"is_active": true,
},
];
const SubscriptionsData = [
{
"name": "Basic Monthly",
"description": "Access to standard catalog with ads.",
"price": 4.99,
"currency": "sar",
"billing_period": "weekly",
"is_active": true,
"max_devices": 1,
"ads_enabled": true,
"features": "SD streaming and limited downloads",
},
{
"name": "Standard Monthly",
"description": "HD streaming with fewer ads and more devices.",
"price": 8.99,
"currency": "egp",
"billing_period": "yearly",
"is_active": true,
"max_devices": 2,
"ads_enabled": true,
"features": "HD streaming and offline viewing",
},
{
"name": "Premium Monthly",
"description": "Ad free experience with best quality and more devices.",
"price": 12.99,
"currency": "gbp",
"billing_period": "quarterly",
"is_active": true,
"max_devices": 4,
"ads_enabled": false,
"features": "4K where available and priority support",
},
{
"name": "Annual Standard",
"description": "One year access at a discounted rate.",
"price": 89.99,
"currency": "usd",
"billing_period": "yearly",
"is_active": true,
"max_devices": 2,
"ads_enabled": true,
"features": "HD streaming billed yearly",
},
{
"name": "Student Plan",
"description": "Discounted plan for eligible students.",
"price": 5.49,
"currency": "sar",
"billing_period": "weekly",
"is_active": false,
"max_devices": 1,
"ads_enabled": true,
"features": "HD streaming with eligibility verification",
},
];
const UserSubscriptionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "trialing",
"start_at": new Date('2026-01-15T00:00:00Z'),
"end_at": new Date('2026-02-15T00:00:00Z'),
"auto_renew": true,
"provider": "stripe",
"provider_reference": "sub_10001",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "expired",
"start_at": new Date('2026-01-28T00:00:00Z'),
"end_at": new Date('2026-02-04T00:00:00Z'),
"auto_renew": true,
"provider": "stripe",
"provider_reference": "sub_10002",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "canceled",
"start_at": new Date('2025-12-10T00:00:00Z'),
"end_at": new Date('2026-01-10T00:00:00Z'),
"auto_renew": true,
"provider": "stripe",
"provider_reference": "sub_10003",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "canceled",
"start_at": new Date('2026-01-01T00:00:00Z'),
"end_at": new Date('2026-02-01T00:00:00Z'),
"auto_renew": true,
"provider": "stripe",
"provider_reference": "sub_10004",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "canceled",
"start_at": new Date('2026-01-01T00:00:00Z'),
"end_at": new Date('2027-01-01T00:00:00Z'),
"auto_renew": true,
"provider": "stripe",
"provider_reference": "sub_10005",
},
];
const PaymentsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"amount": 8.99,
"currency": "egp",
"status": "refunded",
"method": "bank_transfer",
"provider": "stripe",
"provider_payment_reference": "pay_90001",
"paid_at": new Date('2026-01-15T00:05:00Z'),
"refunded_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"amount": 0,
"currency": "gbp",
"status": "refunded",
"method": "google_pay",
"provider": "stripe",
"provider_payment_reference": "pay_90002",
"paid_at": new Date('2026-01-28T00:02:00Z'),
"refunded_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"amount": 4.99,
"currency": "gbp",
"status": "succeeded",
"method": "bank_transfer",
"provider": "stripe",
"provider_payment_reference": "pay_90003",
"paid_at": new Date('2026-01-10T00:03:00Z'),
"refunded_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"amount": 12.99,
"currency": "usd",
"status": "succeeded",
"method": "bank_transfer",
"provider": "stripe",
"provider_payment_reference": "pay_90004",
"paid_at": new Date('2026-01-01T00:02:00Z'),
"refunded_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"amount": 89.99,
"currency": "aed",
"status": "failed",
"method": "paypal",
"provider": "stripe",
"provider_payment_reference": "pay_90005",
"paid_at": new Date('2026-01-01T00:01:00Z'),
"refunded_at": new Date('2026-01-01T00:00:00Z'),
},
];
const WatchHistoryData = [
{
// type code here for "relation_one" field
"target_type": "episode",
// type code here for "relation_one" field
// type code here for "relation_one" field
"progress_seconds": 1800,
"duration_seconds": 6720,
"completed": false,
"last_watched_at": new Date('2026-02-01T20:10:00Z'),
},
{
// type code here for "relation_one" field
"target_type": "episode",
// type code here for "relation_one" field
// type code here for "relation_one" field
"progress_seconds": 2600,
"duration_seconds": 2640,
"completed": true,
"last_watched_at": new Date('2026-01-31T21:05:00Z'),
},
{
// type code here for "relation_one" field
"target_type": "movie",
// type code here for "relation_one" field
// type code here for "relation_one" field
"progress_seconds": 900,
"duration_seconds": 2760,
"completed": false,
"last_watched_at": new Date('2026-02-02T18:22:00Z'),
},
{
// type code here for "relation_one" field
"target_type": "episode",
// type code here for "relation_one" field
// type code here for "relation_one" field
"progress_seconds": 5400,
"duration_seconds": 6240,
"completed": true,
"last_watched_at": new Date('2026-02-03T22:40:00Z'),
},
{
// type code here for "relation_one" field
"target_type": "movie",
// type code here for "relation_one" field
// type code here for "relation_one" field
"progress_seconds": 6720,
"duration_seconds": 6720,
"completed": true,
"last_watched_at": new Date('2026-01-18T19:00:00Z'),
},
];
const FavoritesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"favorited_at": new Date('2026-01-20T11:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"favorited_at": new Date('2026-01-28T16:30:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"favorited_at": new Date('2026-02-01T09:12:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"favorited_at": new Date('2026-01-12T08:05:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"favorited_at": new Date('2026-01-05T10:20:00Z'),
},
];
const ReviewsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 8,
"review_text": "Strong pacing and excellent action scenes with a satisfying ending.",
"status": "approved",
"submitted_at": new Date('2026-01-22T12:10:00Z'),
"moderated_at": new Date('2026-01-22T15:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 9,
"review_text": "Great performances and an engaging story that keeps improving each episode.",
"status": "pending",
"submitted_at": new Date('2026-02-01T10:10:00Z'),
"moderated_at": new Date('2026-02-01T13:40:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 7,
"review_text": "Interesting concept and tense moments, but the middle act feels slow.",
"status": "approved",
"submitted_at": new Date('2026-01-29T17:05:00Z'),
"moderated_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 6,
"review_text": "Well shot but the story is predictable compared to similar films.",
"status": "pending",
"submitted_at": new Date('2026-01-18T09:25:00Z'),
"moderated_at": new Date('2026-01-18T11:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 7,
"review_text": "Light and enjoyable with a few standout jokes and a good cast.",
"status": "approved",
"submitted_at": new Date('2026-02-02T14:30:00Z'),
"moderated_at": new Date('2026-01-01T00:00:00Z'),
},
];
const AdsData = [
{
"name": "Home Banner Q1",
"ad_type": "pre_roll",
"provider": "adsense",
"placement_key": "home_top_banner",
"creative_tag": "<div>Home Banner Q1</div>",
"start_at": new Date('2026-01-01T00:00:00Z'),
"end_at": new Date('2026-03-31T23:59:59Z'),
"is_active": true,
"cpm": 1.2,
"frequency_cap_per_day": 10,
},
{
"name": "Pre Roll Action Pack",
"ad_type": "post_roll",
"provider": "admob",
"placement_key": "player_preroll",
"creative_tag": "<vast>preroll_action_pack</vast>",
"start_at": new Date('2026-01-15T00:00:00Z'),
"end_at": new Date('2026-04-15T23:59:59Z'),
"is_active": true,
"cpm": 3.5,
"frequency_cap_per_day": 6,
},
{
"name": "Mid Roll Series Slot",
"ad_type": "banner",
"provider": "custom",
"placement_key": "player_midroll",
"creative_tag": "<vast>midroll_series_slot</vast>",
"start_at": new Date('2026-02-01T00:00:00Z'),
"end_at": new Date('2026-05-01T23:59:59Z'),
"is_active": true,
"cpm": 4.1,
"frequency_cap_per_day": 4,
},
{
"name": "Post Roll Promo",
"ad_type": "mid_roll",
"provider": "admob",
"placement_key": "player_postroll",
"creative_tag": "<div>Post Roll Promo</div>",
"start_at": new Date('2026-01-10T00:00:00Z'),
"end_at": new Date('2026-02-28T23:59:59Z'),
"is_active": false,
"cpm": 0.9,
"frequency_cap_per_day": 8,
},
{
"name": "Native Recommendations",
"ad_type": "post_roll",
"provider": "custom",
"placement_key": "recommendations_native",
"creative_tag": "<div>Native Recommendations</div>",
"start_at": new Date('2026-01-05T00:00:00Z'),
"end_at": new Date('2026-06-30T23:59:59Z'),
"is_active": true,
"cpm": 2.2,
"frequency_cap_per_day": 12,
},
];
const AdImpressionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_type": "home",
// type code here for "relation_one" field
// type code here for "relation_one" field
"impression_at": new Date('2026-02-01T18:00:00Z'),
"clicked": false,
"client_ip": "203.0.113.10",
"user_agent": "Mozilla 5.0 Chrome 121",
"country": "AE",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_type": "home",
// type code here for "relation_one" field
// type code here for "relation_one" field
"impression_at": new Date('2026-02-01T20:00:10Z'),
"clicked": true,
"client_ip": "203.0.113.10",
"user_agent": "Mozilla 5.0 Chrome 121",
"country": "AE",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_type": "movie",
// type code here for "relation_one" field
// type code here for "relation_one" field
"impression_at": new Date('2026-02-02T18:25:00Z'),
"clicked": false,
"client_ip": "198.51.100.55",
"user_agent": "Mozilla 5.0 Safari 17",
"country": "GB",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_type": "home",
// type code here for "relation_one" field
// type code here for "relation_one" field
"impression_at": new Date('2026-01-29T16:45:00Z'),
"clicked": false,
"client_ip": "192.0.2.44",
"user_agent": "Mozilla 5.0 Firefox 122",
"country": "EG",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_type": "home",
// type code here for "relation_one" field
// type code here for "relation_one" field
"impression_at": new Date('2026-01-25T09:05:00Z'),
"clicked": true,
"client_ip": "203.0.113.77",
"user_agent": "Mozilla 5.0 Chrome 120",
"country": "SA",
},
];
const DevicesData = [
{
// type code here for "relation_one" field
"device_name": "Nora Laptop",
"platform": "ios",
"device_identifier": "dev_nora_web_001",
"last_seen_at": new Date('2026-02-01T20:12:00Z'),
"is_trusted": true,
},
{
// type code here for "relation_one" field
"device_name": "Nora Phone",
"platform": "android",
"device_identifier": "dev_nora_ios_001",
"last_seen_at": new Date('2026-02-01T08:20:00Z'),
"is_trusted": true,
},
{
// type code here for "relation_one" field
"device_name": "Omar Android",
"platform": "tv",
"device_identifier": "dev_omar_android_001",
"last_seen_at": new Date('2026-02-03T22:41:00Z'),
"is_trusted": false,
},
{
// type code here for "relation_one" field
"device_name": "Content Tablet",
"platform": "ios",
"device_identifier": "dev_content_android_001",
"last_seen_at": new Date('2026-02-01T11:10:00Z'),
"is_trusted": true,
},
{
// type code here for "relation_one" field
"device_name": "Owner Desktop",
"platform": "other",
"device_identifier": "dev_owner_web_001",
"last_seen_at": new Date('2026-02-01T09:00:00Z'),
"is_trusted": true,
},
];
const SupportTicketsData = [
{
// type code here for "relation_one" field
"subject": "Playback buffering on WiFi",
"message": "Video buffers frequently when starting an episode on home WiFi.",
"status": "open",
"priority": "medium",
// type code here for "files" field
"opened_at": new Date('2026-02-01T21:00:00Z'),
"closed_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
"subject": "Cannot reset password",
"message": "Password reset email does not arrive after multiple attempts.",
"status": "open",
"priority": "medium",
// type code here for "files" field
"opened_at": new Date('2026-02-02T09:15:00Z'),
"closed_at": new Date('2026-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
"subject": "Subscription payment failed",
"message": "Card payment fails even though the bank confirms it is valid.",
"status": "closed",
"priority": "high",
// type code here for "files" field
"opened_at": new Date('2026-01-10T10:00:00Z'),
"closed_at": new Date('2026-01-12T16:00:00Z'),
},
{
// type code here for "relation_one" field
"subject": "Request access to upload tool",
"message": "Need permission to upload trailers and update metadata for new titles.",
"status": "in_progress",
"priority": "medium",
// type code here for "files" field
"opened_at": new Date('2026-01-05T08:30:00Z'),
"closed_at": new Date('2026-01-05T12:00:00Z'),
},
{
// type code here for "relation_one" field
"subject": "Audio out of sync",
"message": "Audio is slightly delayed compared to video on one movie.",
"status": "closed",
"priority": "low",
// type code here for "files" field
"opened_at": new Date('2026-02-03T08:10:00Z'),
"closed_at": new Date('2026-01-01T00:00:00Z'),
},
];
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateTitleWithStudio() {
const relatedStudio0 = await Studios.findOne({
offset: Math.floor(Math.random() * (await Studios.count())),
});
const Title0 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Title0?.setStudio)
{
await
Title0.
setStudio(relatedStudio0);
}
const relatedStudio1 = await Studios.findOne({
offset: Math.floor(Math.random() * (await Studios.count())),
});
const Title1 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Title1?.setStudio)
{
await
Title1.
setStudio(relatedStudio1);
}
const relatedStudio2 = await Studios.findOne({
offset: Math.floor(Math.random() * (await Studios.count())),
});
const Title2 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Title2?.setStudio)
{
await
Title2.
setStudio(relatedStudio2);
}
const relatedStudio3 = await Studios.findOne({
offset: Math.floor(Math.random() * (await Studios.count())),
});
const Title3 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Title3?.setStudio)
{
await
Title3.
setStudio(relatedStudio3);
}
const relatedStudio4 = await Studios.findOne({
offset: Math.floor(Math.random() * (await Studios.count())),
});
const Title4 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Title4?.setStudio)
{
await
Title4.
setStudio(relatedStudio4);
}
}
// Similar logic for "relation_many"
async function associateTitlePeopleWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const TitlePeople0 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TitlePeople0?.setTitle)
{
await
TitlePeople0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const TitlePeople1 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TitlePeople1?.setTitle)
{
await
TitlePeople1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const TitlePeople2 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TitlePeople2?.setTitle)
{
await
TitlePeople2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const TitlePeople3 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TitlePeople3?.setTitle)
{
await
TitlePeople3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const TitlePeople4 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (TitlePeople4?.setTitle)
{
await
TitlePeople4.
setTitle(relatedTitle4);
}
}
async function associateTitlePeopleWithPerson() {
const relatedPerson0 = await People.findOne({
offset: Math.floor(Math.random() * (await People.count())),
});
const TitlePeople0 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TitlePeople0?.setPerson)
{
await
TitlePeople0.
setPerson(relatedPerson0);
}
const relatedPerson1 = await People.findOne({
offset: Math.floor(Math.random() * (await People.count())),
});
const TitlePeople1 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TitlePeople1?.setPerson)
{
await
TitlePeople1.
setPerson(relatedPerson1);
}
const relatedPerson2 = await People.findOne({
offset: Math.floor(Math.random() * (await People.count())),
});
const TitlePeople2 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TitlePeople2?.setPerson)
{
await
TitlePeople2.
setPerson(relatedPerson2);
}
const relatedPerson3 = await People.findOne({
offset: Math.floor(Math.random() * (await People.count())),
});
const TitlePeople3 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TitlePeople3?.setPerson)
{
await
TitlePeople3.
setPerson(relatedPerson3);
}
const relatedPerson4 = await People.findOne({
offset: Math.floor(Math.random() * (await People.count())),
});
const TitlePeople4 = await TitlePeople.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (TitlePeople4?.setPerson)
{
await
TitlePeople4.
setPerson(relatedPerson4);
}
}
async function associateSeasonWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Season0 = await Seasons.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Season0?.setTitle)
{
await
Season0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Season1 = await Seasons.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Season1?.setTitle)
{
await
Season1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Season2 = await Seasons.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Season2?.setTitle)
{
await
Season2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Season3 = await Seasons.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Season3?.setTitle)
{
await
Season3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Season4 = await Seasons.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Season4?.setTitle)
{
await
Season4.
setTitle(relatedTitle4);
}
}
async function associateEpisodeWithSeason() {
const relatedSeason0 = await Seasons.findOne({
offset: Math.floor(Math.random() * (await Seasons.count())),
});
const Episode0 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Episode0?.setSeason)
{
await
Episode0.
setSeason(relatedSeason0);
}
const relatedSeason1 = await Seasons.findOne({
offset: Math.floor(Math.random() * (await Seasons.count())),
});
const Episode1 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Episode1?.setSeason)
{
await
Episode1.
setSeason(relatedSeason1);
}
const relatedSeason2 = await Seasons.findOne({
offset: Math.floor(Math.random() * (await Seasons.count())),
});
const Episode2 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Episode2?.setSeason)
{
await
Episode2.
setSeason(relatedSeason2);
}
const relatedSeason3 = await Seasons.findOne({
offset: Math.floor(Math.random() * (await Seasons.count())),
});
const Episode3 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Episode3?.setSeason)
{
await
Episode3.
setSeason(relatedSeason3);
}
const relatedSeason4 = await Seasons.findOne({
offset: Math.floor(Math.random() * (await Seasons.count())),
});
const Episode4 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Episode4?.setSeason)
{
await
Episode4.
setSeason(relatedSeason4);
}
}
async function associateVideoSourceWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const VideoSource0 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (VideoSource0?.setTitle)
{
await
VideoSource0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const VideoSource1 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (VideoSource1?.setTitle)
{
await
VideoSource1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const VideoSource2 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (VideoSource2?.setTitle)
{
await
VideoSource2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const VideoSource3 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (VideoSource3?.setTitle)
{
await
VideoSource3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const VideoSource4 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (VideoSource4?.setTitle)
{
await
VideoSource4.
setTitle(relatedTitle4);
}
}
async function associateVideoSourceWithEpisode() {
const relatedEpisode0 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const VideoSource0 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (VideoSource0?.setEpisode)
{
await
VideoSource0.
setEpisode(relatedEpisode0);
}
const relatedEpisode1 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const VideoSource1 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (VideoSource1?.setEpisode)
{
await
VideoSource1.
setEpisode(relatedEpisode1);
}
const relatedEpisode2 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const VideoSource2 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (VideoSource2?.setEpisode)
{
await
VideoSource2.
setEpisode(relatedEpisode2);
}
const relatedEpisode3 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const VideoSource3 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (VideoSource3?.setEpisode)
{
await
VideoSource3.
setEpisode(relatedEpisode3);
}
const relatedEpisode4 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const VideoSource4 = await VideoSources.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (VideoSource4?.setEpisode)
{
await
VideoSource4.
setEpisode(relatedEpisode4);
}
}
async function associateUserSubscriptionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSubscription0 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UserSubscription0?.setUser)
{
await
UserSubscription0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSubscription1 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UserSubscription1?.setUser)
{
await
UserSubscription1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSubscription2 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UserSubscription2?.setUser)
{
await
UserSubscription2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSubscription3 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UserSubscription3?.setUser)
{
await
UserSubscription3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSubscription4 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (UserSubscription4?.setUser)
{
await
UserSubscription4.
setUser(relatedUser4);
}
}
async function associateUserSubscriptionWithSubscription() {
const relatedSubscription0 = await Subscriptions.findOne({
offset: Math.floor(Math.random() * (await Subscriptions.count())),
});
const UserSubscription0 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UserSubscription0?.setSubscription)
{
await
UserSubscription0.
setSubscription(relatedSubscription0);
}
const relatedSubscription1 = await Subscriptions.findOne({
offset: Math.floor(Math.random() * (await Subscriptions.count())),
});
const UserSubscription1 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UserSubscription1?.setSubscription)
{
await
UserSubscription1.
setSubscription(relatedSubscription1);
}
const relatedSubscription2 = await Subscriptions.findOne({
offset: Math.floor(Math.random() * (await Subscriptions.count())),
});
const UserSubscription2 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UserSubscription2?.setSubscription)
{
await
UserSubscription2.
setSubscription(relatedSubscription2);
}
const relatedSubscription3 = await Subscriptions.findOne({
offset: Math.floor(Math.random() * (await Subscriptions.count())),
});
const UserSubscription3 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UserSubscription3?.setSubscription)
{
await
UserSubscription3.
setSubscription(relatedSubscription3);
}
const relatedSubscription4 = await Subscriptions.findOne({
offset: Math.floor(Math.random() * (await Subscriptions.count())),
});
const UserSubscription4 = await UserSubscriptions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (UserSubscription4?.setSubscription)
{
await
UserSubscription4.
setSubscription(relatedSubscription4);
}
}
async function associatePaymentWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setUser)
{
await
Payment0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setUser)
{
await
Payment1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setUser)
{
await
Payment2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setUser)
{
await
Payment3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setUser)
{
await
Payment4.
setUser(relatedUser4);
}
}
async function associatePaymentWithUser_subscription() {
const relatedUser_subscription0 = await UserSubscriptions.findOne({
offset: Math.floor(Math.random() * (await UserSubscriptions.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setUser_subscription)
{
await
Payment0.
setUser_subscription(relatedUser_subscription0);
}
const relatedUser_subscription1 = await UserSubscriptions.findOne({
offset: Math.floor(Math.random() * (await UserSubscriptions.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setUser_subscription)
{
await
Payment1.
setUser_subscription(relatedUser_subscription1);
}
const relatedUser_subscription2 = await UserSubscriptions.findOne({
offset: Math.floor(Math.random() * (await UserSubscriptions.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setUser_subscription)
{
await
Payment2.
setUser_subscription(relatedUser_subscription2);
}
const relatedUser_subscription3 = await UserSubscriptions.findOne({
offset: Math.floor(Math.random() * (await UserSubscriptions.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setUser_subscription)
{
await
Payment3.
setUser_subscription(relatedUser_subscription3);
}
const relatedUser_subscription4 = await UserSubscriptions.findOne({
offset: Math.floor(Math.random() * (await UserSubscriptions.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setUser_subscription)
{
await
Payment4.
setUser_subscription(relatedUser_subscription4);
}
}
async function associateWatchHistoryWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchHistory0 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WatchHistory0?.setUser)
{
await
WatchHistory0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchHistory1 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WatchHistory1?.setUser)
{
await
WatchHistory1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchHistory2 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WatchHistory2?.setUser)
{
await
WatchHistory2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchHistory3 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WatchHistory3?.setUser)
{
await
WatchHistory3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchHistory4 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (WatchHistory4?.setUser)
{
await
WatchHistory4.
setUser(relatedUser4);
}
}
async function associateWatchHistoryWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const WatchHistory0 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WatchHistory0?.setTitle)
{
await
WatchHistory0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const WatchHistory1 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WatchHistory1?.setTitle)
{
await
WatchHistory1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const WatchHistory2 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WatchHistory2?.setTitle)
{
await
WatchHistory2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const WatchHistory3 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WatchHistory3?.setTitle)
{
await
WatchHistory3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const WatchHistory4 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (WatchHistory4?.setTitle)
{
await
WatchHistory4.
setTitle(relatedTitle4);
}
}
async function associateWatchHistoryWithEpisode() {
const relatedEpisode0 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const WatchHistory0 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WatchHistory0?.setEpisode)
{
await
WatchHistory0.
setEpisode(relatedEpisode0);
}
const relatedEpisode1 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const WatchHistory1 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WatchHistory1?.setEpisode)
{
await
WatchHistory1.
setEpisode(relatedEpisode1);
}
const relatedEpisode2 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const WatchHistory2 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WatchHistory2?.setEpisode)
{
await
WatchHistory2.
setEpisode(relatedEpisode2);
}
const relatedEpisode3 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const WatchHistory3 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WatchHistory3?.setEpisode)
{
await
WatchHistory3.
setEpisode(relatedEpisode3);
}
const relatedEpisode4 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const WatchHistory4 = await WatchHistory.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (WatchHistory4?.setEpisode)
{
await
WatchHistory4.
setEpisode(relatedEpisode4);
}
}
async function associateFavoriteWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Favorite0 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Favorite0?.setUser)
{
await
Favorite0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Favorite1 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Favorite1?.setUser)
{
await
Favorite1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Favorite2 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Favorite2?.setUser)
{
await
Favorite2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Favorite3 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Favorite3?.setUser)
{
await
Favorite3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Favorite4 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Favorite4?.setUser)
{
await
Favorite4.
setUser(relatedUser4);
}
}
async function associateFavoriteWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Favorite0 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Favorite0?.setTitle)
{
await
Favorite0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Favorite1 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Favorite1?.setTitle)
{
await
Favorite1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Favorite2 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Favorite2?.setTitle)
{
await
Favorite2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Favorite3 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Favorite3?.setTitle)
{
await
Favorite3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Favorite4 = await Favorites.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Favorite4?.setTitle)
{
await
Favorite4.
setTitle(relatedTitle4);
}
}
async function associateReviewWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Review0 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Review0?.setUser)
{
await
Review0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Review1 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Review1?.setUser)
{
await
Review1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Review2 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Review2?.setUser)
{
await
Review2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Review3 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Review3?.setUser)
{
await
Review3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Review4 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Review4?.setUser)
{
await
Review4.
setUser(relatedUser4);
}
}
async function associateReviewWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Review0 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Review0?.setTitle)
{
await
Review0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Review1 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Review1?.setTitle)
{
await
Review1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Review2 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Review2?.setTitle)
{
await
Review2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Review3 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Review3?.setTitle)
{
await
Review3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const Review4 = await Reviews.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Review4?.setTitle)
{
await
Review4.
setTitle(relatedTitle4);
}
}
async function associateAdImpressionWithAd() {
const relatedAd0 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdImpression0 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdImpression0?.setAd)
{
await
AdImpression0.
setAd(relatedAd0);
}
const relatedAd1 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdImpression1 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdImpression1?.setAd)
{
await
AdImpression1.
setAd(relatedAd1);
}
const relatedAd2 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdImpression2 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdImpression2?.setAd)
{
await
AdImpression2.
setAd(relatedAd2);
}
const relatedAd3 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdImpression3 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdImpression3?.setAd)
{
await
AdImpression3.
setAd(relatedAd3);
}
const relatedAd4 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdImpression4 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AdImpression4?.setAd)
{
await
AdImpression4.
setAd(relatedAd4);
}
}
async function associateAdImpressionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdImpression0 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdImpression0?.setUser)
{
await
AdImpression0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdImpression1 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdImpression1?.setUser)
{
await
AdImpression1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdImpression2 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdImpression2?.setUser)
{
await
AdImpression2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdImpression3 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdImpression3?.setUser)
{
await
AdImpression3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdImpression4 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AdImpression4?.setUser)
{
await
AdImpression4.
setUser(relatedUser4);
}
}
async function associateAdImpressionWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const AdImpression0 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdImpression0?.setTitle)
{
await
AdImpression0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const AdImpression1 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdImpression1?.setTitle)
{
await
AdImpression1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const AdImpression2 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdImpression2?.setTitle)
{
await
AdImpression2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const AdImpression3 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdImpression3?.setTitle)
{
await
AdImpression3.
setTitle(relatedTitle3);
}
const relatedTitle4 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const AdImpression4 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AdImpression4?.setTitle)
{
await
AdImpression4.
setTitle(relatedTitle4);
}
}
async function associateAdImpressionWithEpisode() {
const relatedEpisode0 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const AdImpression0 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdImpression0?.setEpisode)
{
await
AdImpression0.
setEpisode(relatedEpisode0);
}
const relatedEpisode1 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const AdImpression1 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdImpression1?.setEpisode)
{
await
AdImpression1.
setEpisode(relatedEpisode1);
}
const relatedEpisode2 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const AdImpression2 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdImpression2?.setEpisode)
{
await
AdImpression2.
setEpisode(relatedEpisode2);
}
const relatedEpisode3 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const AdImpression3 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdImpression3?.setEpisode)
{
await
AdImpression3.
setEpisode(relatedEpisode3);
}
const relatedEpisode4 = await Episodes.findOne({
offset: Math.floor(Math.random() * (await Episodes.count())),
});
const AdImpression4 = await AdImpressions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AdImpression4?.setEpisode)
{
await
AdImpression4.
setEpisode(relatedEpisode4);
}
}
async function associateDeviceWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Device0 = await Devices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Device0?.setUser)
{
await
Device0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Device1 = await Devices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Device1?.setUser)
{
await
Device1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Device2 = await Devices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Device2?.setUser)
{
await
Device2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Device3 = await Devices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Device3?.setUser)
{
await
Device3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Device4 = await Devices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Device4?.setUser)
{
await
Device4.
setUser(relatedUser4);
}
}
async function associateSupportTicketWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SupportTicket0 = await SupportTickets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SupportTicket0?.setUser)
{
await
SupportTicket0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SupportTicket1 = await SupportTickets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SupportTicket1?.setUser)
{
await
SupportTicket1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SupportTicket2 = await SupportTickets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SupportTicket2?.setUser)
{
await
SupportTicket2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SupportTicket3 = await SupportTickets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SupportTicket3?.setUser)
{
await
SupportTicket3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SupportTicket4 = await SupportTickets.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (SupportTicket4?.setUser)
{
await
SupportTicket4.
setUser(relatedUser4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Genres.bulkCreate(GenresData);
await People.bulkCreate(PeopleData);
await Studios.bulkCreate(StudiosData);
await Titles.bulkCreate(TitlesData);
await TitlePeople.bulkCreate(TitlePeopleData);
await Seasons.bulkCreate(SeasonsData);
await Episodes.bulkCreate(EpisodesData);
await VideoSources.bulkCreate(VideoSourcesData);
await Subscriptions.bulkCreate(SubscriptionsData);
await UserSubscriptions.bulkCreate(UserSubscriptionsData);
await Payments.bulkCreate(PaymentsData);
await WatchHistory.bulkCreate(WatchHistoryData);
await Favorites.bulkCreate(FavoritesData);
await Reviews.bulkCreate(ReviewsData);
await Ads.bulkCreate(AdsData);
await AdImpressions.bulkCreate(AdImpressionsData);
await Devices.bulkCreate(DevicesData);
await SupportTickets.bulkCreate(SupportTicketsData);
await Promise.all([
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateTitleWithStudio(),
// Similar logic for "relation_many"
await associateTitlePeopleWithTitle(),
await associateTitlePeopleWithPerson(),
await associateSeasonWithTitle(),
await associateEpisodeWithSeason(),
await associateVideoSourceWithTitle(),
await associateVideoSourceWithEpisode(),
await associateUserSubscriptionWithUser(),
await associateUserSubscriptionWithSubscription(),
await associatePaymentWithUser(),
await associatePaymentWithUser_subscription(),
await associateWatchHistoryWithUser(),
await associateWatchHistoryWithTitle(),
await associateWatchHistoryWithEpisode(),
await associateFavoriteWithUser(),
await associateFavoriteWithTitle(),
await associateReviewWithUser(),
await associateReviewWithTitle(),
await associateAdImpressionWithAd(),
await associateAdImpressionWithUser(),
await associateAdImpressionWithTitle(),
await associateAdImpressionWithEpisode(),
await associateDeviceWithUser(),
await associateSupportTicketWithUser(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('genres', null, {});
await queryInterface.bulkDelete('people', null, {});
await queryInterface.bulkDelete('studios', null, {});
await queryInterface.bulkDelete('titles', null, {});
await queryInterface.bulkDelete('title_people', null, {});
await queryInterface.bulkDelete('seasons', null, {});
await queryInterface.bulkDelete('episodes', null, {});
await queryInterface.bulkDelete('video_sources', null, {});
await queryInterface.bulkDelete('subscriptions', null, {});
await queryInterface.bulkDelete('user_subscriptions', null, {});
await queryInterface.bulkDelete('payments', null, {});
await queryInterface.bulkDelete('watch_history', null, {});
await queryInterface.bulkDelete('favorites', null, {});
await queryInterface.bulkDelete('reviews', null, {});
await queryInterface.bulkDelete('ads', null, {});
await queryInterface.bulkDelete('ad_impressions', null, {});
await queryInterface.bulkDelete('devices', null, {});
await queryInterface.bulkDelete('support_tickets', null, {});
},
};