39506-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-04-06 16:56:27 +00:00

7309 lines
134 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Profiles = db.profiles;
const Subscriptions = db.subscriptions;
const Genres = db.genres;
const ContentCollections = db.content_collections;
const Videos = db.videos;
const Titles = db.titles;
const Seasons = db.seasons;
const Episodes = db.episodes;
const WatchProgress = db.watch_progress;
const MyListItems = db.my_list_items;
const Reviews = db.reviews;
const SportsLeagues = db.sports_leagues;
const SportsTeams = db.sports_teams;
const SportsSeasons = db.sports_seasons;
const Venues = db.venues;
const Matches = db.matches;
const MatchEvents = db.match_events;
const SportsArticles = db.sports_articles;
const ProfilesData = [
{
// type code here for "relation_one" field
"display_name": "Ada Lovelace",
"bio": "Ada Lovelace",
"country": "Marie Curie",
"language": "Ada Lovelace",
"theme_preference": "netflix_dark",
"kid_mode": true,
"date_of_birth": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"display_name": "Marie Curie",
"bio": "Alan Turing",
"country": "Grace Hopper",
"language": "Alan Turing",
"theme_preference": "espn_sports",
"kid_mode": true,
"date_of_birth": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"display_name": "Grace Hopper",
"bio": "Alan Turing",
"country": "Ada Lovelace",
"language": "Grace Hopper",
"theme_preference": "netflix_dark",
"kid_mode": true,
"date_of_birth": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"display_name": "Marie Curie",
"bio": "Ada Lovelace",
"country": "Grace Hopper",
"language": "Marie Curie",
"theme_preference": "netflix_dark",
"kid_mode": true,
"date_of_birth": new Date(Date.now()),
},
];
const SubscriptionsData = [
{
// type code here for "relation_one" field
"plan": "standard",
"status": "active",
"started_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"canceled_at": new Date(Date.now()),
"auto_renew": false,
"price": 2.47,
"currency": "Ada Lovelace",
"provider": "Ada Lovelace",
"provider_subscription_ref": "Marie Curie",
},
{
// type code here for "relation_one" field
"plan": "basic",
"status": "active",
"started_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"canceled_at": new Date(Date.now()),
"auto_renew": false,
"price": 8.57,
"currency": "Grace Hopper",
"provider": "Marie Curie",
"provider_subscription_ref": "Alan Turing",
},
{
// type code here for "relation_one" field
"plan": "free",
"status": "past_due",
"started_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"canceled_at": new Date(Date.now()),
"auto_renew": false,
"price": 5.66,
"currency": "Alan Turing",
"provider": "Marie Curie",
"provider_subscription_ref": "Ada Lovelace",
},
{
// type code here for "relation_one" field
"plan": "basic",
"status": "past_due",
"started_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"canceled_at": new Date(Date.now()),
"auto_renew": true,
"price": 5.63,
"currency": "Marie Curie",
"provider": "Grace Hopper",
"provider_subscription_ref": "Alan Turing",
},
];
const GenresData = [
{
"name": "Ada Lovelace",
"slug": "Alan Turing",
"description": "Alan Turing",
"category_type": "movies",
"sort_order": 8,
"is_active": false,
},
{
"name": "Grace Hopper",
"slug": "Ada Lovelace",
"description": "Ada Lovelace",
"category_type": "mixed",
"sort_order": 5,
"is_active": false,
},
{
"name": "Marie Curie",
"slug": "Ada Lovelace",
"description": "Alan Turing",
"category_type": "tv_shows",
"sort_order": 3,
"is_active": false,
},
{
"name": "Grace Hopper",
"slug": "Ada Lovelace",
"description": "Marie Curie",
"category_type": "tv_shows",
"sort_order": 7,
"is_active": false,
},
];
const ContentCollectionsData = [
{
"title": "Marie Curie",
"slug": "Marie Curie",
"collection_type": "continue_watching",
"description": "Marie Curie",
// type code here for "images" field
"sort_order": 9,
"is_active": false,
// type code here for "relation_many" field
},
{
"title": "Alan Turing",
"slug": "Marie Curie",
"collection_type": "top_picks",
"description": "Marie Curie",
// type code here for "images" field
"sort_order": 8,
"is_active": true,
// type code here for "relation_many" field
},
{
"title": "Ada Lovelace",
"slug": "Alan Turing",
"collection_type": "sports_highlights",
"description": "Alan Turing",
// type code here for "images" field
"sort_order": 5,
"is_active": true,
// type code here for "relation_many" field
},
{
"title": "Ada Lovelace",
"slug": "Marie Curie",
"collection_type": "curated_row",
"description": "Alan Turing",
// type code here for "images" field
"sort_order": 4,
"is_active": false,
// type code here for "relation_many" field
},
];
const VideosData = [
{
"title": "Ada Lovelace",
"video_type": "episode",
"source_type": "dash",
"source_url": "Grace Hopper",
// type code here for "files" field
// type code here for "images" field
"duration_seconds": 2,
"maturity_rating": "g",
"is_public": false,
"published_at": new Date(Date.now()),
},
{
"title": "Grace Hopper",
"video_type": "teaser",
"source_type": "external_url",
"source_url": "Ada Lovelace",
// type code here for "files" field
// type code here for "images" field
"duration_seconds": 1,
"maturity_rating": "tv_14",
"is_public": false,
"published_at": new Date(Date.now()),
},
{
"title": "Ada Lovelace",
"video_type": "teaser",
"source_type": "vimeo",
"source_url": "Ada Lovelace",
// type code here for "files" field
// type code here for "images" field
"duration_seconds": 6,
"maturity_rating": "tv_ma",
"is_public": true,
"published_at": new Date(Date.now()),
},
{
"title": "Ada Lovelace",
"video_type": "highlight",
"source_type": "hls",
"source_url": "Ada Lovelace",
// type code here for "files" field
// type code here for "images" field
"duration_seconds": 1,
"maturity_rating": "nc_17",
"is_public": true,
"published_at": new Date(Date.now()),
},
];
const TitlesData = [
{
"name": "Marie Curie",
"slug": "Marie Curie",
"title_type": "movie",
"synopsis": "Alan Turing",
"maturity_rating": "tv_14",
"release_date": new Date(Date.now()),
"runtime_minutes": 5,
"original_language": "Ada Lovelace",
"imdb_rating": 2.28,
// type code here for "images" field
// type code here for "images" field
"is_featured": false,
"status": "archived",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "Grace Hopper",
"slug": "Grace Hopper",
"title_type": "movie",
"synopsis": "Alan Turing",
"maturity_rating": "tv_14",
"release_date": new Date(Date.now()),
"runtime_minutes": 5,
"original_language": "Alan Turing",
"imdb_rating": 4.55,
// type code here for "images" field
// type code here for "images" field
"is_featured": true,
"status": "archived",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "Grace Hopper",
"slug": "Marie Curie",
"title_type": "tv_show",
"synopsis": "Ada Lovelace",
"maturity_rating": "tv_g",
"release_date": new Date(Date.now()),
"runtime_minutes": 4,
"original_language": "Alan Turing",
"imdb_rating": 6.53,
// type code here for "images" field
// type code here for "images" field
"is_featured": false,
"status": "draft",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
{
"name": "Marie Curie",
"slug": "Grace Hopper",
"title_type": "movie",
"synopsis": "Alan Turing",
"maturity_rating": "nc_17",
"release_date": new Date(Date.now()),
"runtime_minutes": 9,
"original_language": "Alan Turing",
"imdb_rating": 8.93,
// type code here for "images" field
// type code here for "images" field
"is_featured": true,
"status": "archived",
// type code here for "relation_many" field
// type code here for "relation_one" field
},
];
const SeasonsData = [
{
// type code here for "relation_one" field
"name": "Marie Curie",
"season_number": 1,
"overview": "Alan Turing",
// type code here for "images" field
"release_date": new Date(Date.now()),
"status": "published",
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"season_number": 3,
"overview": "Grace Hopper",
// type code here for "images" field
"release_date": new Date(Date.now()),
"status": "archived",
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"season_number": 4,
"overview": "Ada Lovelace",
// type code here for "images" field
"release_date": new Date(Date.now()),
"status": "draft",
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"season_number": 8,
"overview": "Grace Hopper",
// type code here for "images" field
"release_date": new Date(Date.now()),
"status": "draft",
},
];
const EpisodesData = [
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"episode_number": 6,
"overview": "Grace Hopper",
"air_date": new Date(Date.now()),
"runtime_minutes": 2,
// type code here for "images" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "draft",
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"episode_number": 9,
"overview": "Grace Hopper",
"air_date": new Date(Date.now()),
"runtime_minutes": 6,
// type code here for "images" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "archived",
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"episode_number": 2,
"overview": "Ada Lovelace",
"air_date": new Date(Date.now()),
"runtime_minutes": 1,
// type code here for "images" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "published",
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"episode_number": 1,
"overview": "Ada Lovelace",
"air_date": new Date(Date.now()),
"runtime_minutes": 8,
// type code here for "images" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "archived",
},
];
const WatchProgressData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"position_seconds": 4,
"duration_seconds": 4,
"is_completed": false,
"last_watched_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"position_seconds": 9,
"duration_seconds": 7,
"is_completed": false,
"last_watched_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"position_seconds": 6,
"duration_seconds": 2,
"is_completed": true,
"last_watched_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"position_seconds": 7,
"duration_seconds": 6,
"is_completed": true,
"last_watched_at": new Date(Date.now()),
},
];
const MyListItemsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"added_at": new Date(Date.now()),
"list_type": "watch_later",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"added_at": new Date(Date.now()),
"list_type": "watch_later",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"added_at": new Date(Date.now()),
"list_type": "favorites",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"added_at": new Date(Date.now()),
"list_type": "favorites",
},
];
const ReviewsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 1,
"headline": "Grace Hopper",
"body": "Alan Turing",
"status": "pending",
"submitted_at": new Date(Date.now()),
"moderated_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 3,
"headline": "Marie Curie",
"body": "Marie Curie",
"status": "approved",
"submitted_at": new Date(Date.now()),
"moderated_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 8,
"headline": "Alan Turing",
"body": "Grace Hopper",
"status": "approved",
"submitted_at": new Date(Date.now()),
"moderated_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"rating": 9,
"headline": "Alan Turing",
"body": "Alan Turing",
"status": "approved",
"submitted_at": new Date(Date.now()),
"moderated_at": new Date(Date.now()),
},
];
const SportsLeaguesData = [
{
"name": "Marie Curie",
"slug": "Alan Turing",
"sport_type": "football",
"country": "Marie Curie",
// type code here for "images" field
"is_active": false,
},
{
"name": "Alan Turing",
"slug": "Ada Lovelace",
"sport_type": "football",
"country": "Ada Lovelace",
// type code here for "images" field
"is_active": true,
},
{
"name": "Grace Hopper",
"slug": "Alan Turing",
"sport_type": "football",
"country": "Marie Curie",
// type code here for "images" field
"is_active": false,
},
{
"name": "Marie Curie",
"slug": "Alan Turing",
"sport_type": "football",
"country": "Alan Turing",
// type code here for "images" field
"is_active": false,
},
];
const SportsTeamsData = [
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"short_name": "Alan Turing",
"abbreviation": "Ada Lovelace",
"city": "Ada Lovelace",
// type code here for "images" field
"primary_color": "Grace Hopper",
"secondary_color": "Marie Curie",
"is_active": false,
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"short_name": "Alan Turing",
"abbreviation": "Grace Hopper",
"city": "Ada Lovelace",
// type code here for "images" field
"primary_color": "Alan Turing",
"secondary_color": "Grace Hopper",
"is_active": false,
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"short_name": "Grace Hopper",
"abbreviation": "Alan Turing",
"city": "Ada Lovelace",
// type code here for "images" field
"primary_color": "Ada Lovelace",
"secondary_color": "Grace Hopper",
"is_active": true,
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"short_name": "Marie Curie",
"abbreviation": "Ada Lovelace",
"city": "Marie Curie",
// type code here for "images" field
"primary_color": "Alan Turing",
"secondary_color": "Marie Curie",
"is_active": false,
},
];
const SportsSeasonsData = [
{
// type code here for "relation_one" field
"name": "Marie Curie",
"year_start": 8,
"year_end": 2,
"start_date": new Date(Date.now()),
"end_date": new Date(Date.now()),
"status": "scheduled",
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"year_start": 8,
"year_end": 9,
"start_date": new Date(Date.now()),
"end_date": new Date(Date.now()),
"status": "scheduled",
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"year_start": 5,
"year_end": 4,
"start_date": new Date(Date.now()),
"end_date": new Date(Date.now()),
"status": "completed",
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"year_start": 9,
"year_end": 4,
"start_date": new Date(Date.now()),
"end_date": new Date(Date.now()),
"status": "archived",
},
];
const VenuesData = [
{
"name": "Ada Lovelace",
"city": "Alan Turing",
"country": "Ada Lovelace",
"address": "Grace Hopper",
"capacity": 9,
"latitude": 7.59,
"longitude": 1.47,
// type code here for "images" field
},
{
"name": "Ada Lovelace",
"city": "Marie Curie",
"country": "Marie Curie",
"address": "Alan Turing",
"capacity": 2,
"latitude": 8.46,
"longitude": 3.69,
// type code here for "images" field
},
{
"name": "Marie Curie",
"city": "Alan Turing",
"country": "Alan Turing",
"address": "Marie Curie",
"capacity": 1,
"latitude": 1.24,
"longitude": 4.42,
// type code here for "images" field
},
{
"name": "Marie Curie",
"city": "Alan Turing",
"country": "Grace Hopper",
"address": "Grace Hopper",
"capacity": 7,
"latitude": 4.88,
"longitude": 4.51,
// type code here for "images" field
},
];
const MatchesData = [
{
// 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 "relation_one" field
// type code here for "relation_one" field
"kickoff_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"match_status": "postponed",
"home_score": 8,
"away_score": 4,
"round_name": "Ada Lovelace",
"match_day_label": "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 "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"kickoff_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"match_status": "finished",
"home_score": 5,
"away_score": 5,
"round_name": "Grace Hopper",
"match_day_label": "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 "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"kickoff_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"match_status": "halftime",
"home_score": 3,
"away_score": 2,
"round_name": "Alan Turing",
"match_day_label": "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 "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"kickoff_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"match_status": "postponed",
"home_score": 2,
"away_score": 9,
"round_name": "Marie Curie",
"match_day_label": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const MatchEventsData = [
{
// type code here for "relation_one" field
"event_type": "kickoff",
"minute": 7,
"stoppage_minute": 2,
"player_name": "Alan Turing",
"notes": "Ada Lovelace",
"team_side": "away",
},
{
// type code here for "relation_one" field
"event_type": "goal",
"minute": 4,
"stoppage_minute": 2,
"player_name": "Alan Turing",
"notes": "Grace Hopper",
"team_side": "home",
},
{
// type code here for "relation_one" field
"event_type": "assist",
"minute": 9,
"stoppage_minute": 9,
"player_name": "Alan Turing",
"notes": "Alan Turing",
"team_side": "away",
},
{
// type code here for "relation_one" field
"event_type": "penalty_scored",
"minute": 3,
"stoppage_minute": 5,
"player_name": "Marie Curie",
"notes": "Marie Curie",
"team_side": "home",
},
];
const SportsArticlesData = [
{
// type code here for "relation_one" field
"title": "Alan Turing",
"slug": "Alan Turing",
"excerpt": "Alan Turing",
"body": "Alan Turing",
// type code here for "images" field
"status": "published",
"published_at": new Date(Date.now()),
"source_name": "Grace Hopper",
"source_url": "Grace Hopper",
},
{
// type code here for "relation_one" field
"title": "Grace Hopper",
"slug": "Marie Curie",
"excerpt": "Grace Hopper",
"body": "Ada Lovelace",
// type code here for "images" field
"status": "draft",
"published_at": new Date(Date.now()),
"source_name": "Marie Curie",
"source_url": "Alan Turing",
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"slug": "Ada Lovelace",
"excerpt": "Grace Hopper",
"body": "Marie Curie",
// type code here for "images" field
"status": "draft",
"published_at": new Date(Date.now()),
"source_name": "Marie Curie",
"source_url": "Ada Lovelace",
},
{
// type code here for "relation_one" field
"title": "Marie Curie",
"slug": "Ada Lovelace",
"excerpt": "Alan Turing",
"body": "Grace Hopper",
// type code here for "images" field
"status": "published",
"published_at": new Date(Date.now()),
"source_name": "Marie Curie",
"source_url": "Marie Curie",
},
];
// Similar logic for "relation_many"
async function associateProfileWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Profile0 = await Profiles.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Profile0?.setUser)
{
await
Profile0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Profile1 = await Profiles.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Profile1?.setUser)
{
await
Profile1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Profile2 = await Profiles.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Profile2?.setUser)
{
await
Profile2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Profile3 = await Profiles.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Profile3?.setUser)
{
await
Profile3.
setUser(relatedUser3);
}
}
async function associateSubscriptionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Subscription0 = await Subscriptions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Subscription0?.setUser)
{
await
Subscription0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Subscription1 = await Subscriptions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Subscription1?.setUser)
{
await
Subscription1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Subscription2 = await Subscriptions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Subscription2?.setUser)
{
await
Subscription2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Subscription3 = await Subscriptions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Subscription3?.setUser)
{
await
Subscription3.
setUser(relatedUser3);
}
}
// Similar logic for "relation_many"
// Similar logic for "relation_many"
async function associateTitleWithPrimary_trailer() {
const relatedPrimary_trailer0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Title0 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Title0?.setPrimary_trailer)
{
await
Title0.
setPrimary_trailer(relatedPrimary_trailer0);
}
const relatedPrimary_trailer1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Title1 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Title1?.setPrimary_trailer)
{
await
Title1.
setPrimary_trailer(relatedPrimary_trailer1);
}
const relatedPrimary_trailer2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Title2 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Title2?.setPrimary_trailer)
{
await
Title2.
setPrimary_trailer(relatedPrimary_trailer2);
}
const relatedPrimary_trailer3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Title3 = await Titles.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Title3?.setPrimary_trailer)
{
await
Title3.
setPrimary_trailer(relatedPrimary_trailer3);
}
}
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);
}
}
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);
}
}
async function associateEpisodeWithPlayback_video() {
const relatedPlayback_video0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode0 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Episode0?.setPlayback_video)
{
await
Episode0.
setPlayback_video(relatedPlayback_video0);
}
const relatedPlayback_video1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode1 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Episode1?.setPlayback_video)
{
await
Episode1.
setPlayback_video(relatedPlayback_video1);
}
const relatedPlayback_video2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode2 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Episode2?.setPlayback_video)
{
await
Episode2.
setPlayback_video(relatedPlayback_video2);
}
const relatedPlayback_video3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode3 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Episode3?.setPlayback_video)
{
await
Episode3.
setPlayback_video(relatedPlayback_video3);
}
}
async function associateEpisodeWithTrailer_video() {
const relatedTrailer_video0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode0 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Episode0?.setTrailer_video)
{
await
Episode0.
setTrailer_video(relatedTrailer_video0);
}
const relatedTrailer_video1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode1 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Episode1?.setTrailer_video)
{
await
Episode1.
setTrailer_video(relatedTrailer_video1);
}
const relatedTrailer_video2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode2 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Episode2?.setTrailer_video)
{
await
Episode2.
setTrailer_video(relatedTrailer_video2);
}
const relatedTrailer_video3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Episode3 = await Episodes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Episode3?.setTrailer_video)
{
await
Episode3.
setTrailer_video(relatedTrailer_video3);
}
}
async function associateWatchProgresWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchProgres0 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WatchProgres0?.setUser)
{
await
WatchProgres0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchProgres1 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WatchProgres1?.setUser)
{
await
WatchProgres1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchProgres2 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WatchProgres2?.setUser)
{
await
WatchProgres2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WatchProgres3 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WatchProgres3?.setUser)
{
await
WatchProgres3.
setUser(relatedUser3);
}
}
async function associateWatchProgresWithVideo() {
const relatedVideo0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const WatchProgres0 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WatchProgres0?.setVideo)
{
await
WatchProgres0.
setVideo(relatedVideo0);
}
const relatedVideo1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const WatchProgres1 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WatchProgres1?.setVideo)
{
await
WatchProgres1.
setVideo(relatedVideo1);
}
const relatedVideo2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const WatchProgres2 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WatchProgres2?.setVideo)
{
await
WatchProgres2.
setVideo(relatedVideo2);
}
const relatedVideo3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const WatchProgres3 = await WatchProgress.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WatchProgres3?.setVideo)
{
await
WatchProgres3.
setVideo(relatedVideo3);
}
}
async function associateMyListItemWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MyListItem0 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MyListItem0?.setUser)
{
await
MyListItem0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MyListItem1 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MyListItem1?.setUser)
{
await
MyListItem1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MyListItem2 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MyListItem2?.setUser)
{
await
MyListItem2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MyListItem3 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MyListItem3?.setUser)
{
await
MyListItem3.
setUser(relatedUser3);
}
}
async function associateMyListItemWithTitle() {
const relatedTitle0 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const MyListItem0 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MyListItem0?.setTitle)
{
await
MyListItem0.
setTitle(relatedTitle0);
}
const relatedTitle1 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const MyListItem1 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MyListItem1?.setTitle)
{
await
MyListItem1.
setTitle(relatedTitle1);
}
const relatedTitle2 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const MyListItem2 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MyListItem2?.setTitle)
{
await
MyListItem2.
setTitle(relatedTitle2);
}
const relatedTitle3 = await Titles.findOne({
offset: Math.floor(Math.random() * (await Titles.count())),
});
const MyListItem3 = await MyListItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MyListItem3?.setTitle)
{
await
MyListItem3.
setTitle(relatedTitle3);
}
}
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);
}
}
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);
}
}
async function associateSportsTeamWithLeague() {
const relatedLeague0 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsTeam0 = await SportsTeams.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SportsTeam0?.setLeague)
{
await
SportsTeam0.
setLeague(relatedLeague0);
}
const relatedLeague1 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsTeam1 = await SportsTeams.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SportsTeam1?.setLeague)
{
await
SportsTeam1.
setLeague(relatedLeague1);
}
const relatedLeague2 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsTeam2 = await SportsTeams.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SportsTeam2?.setLeague)
{
await
SportsTeam2.
setLeague(relatedLeague2);
}
const relatedLeague3 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsTeam3 = await SportsTeams.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SportsTeam3?.setLeague)
{
await
SportsTeam3.
setLeague(relatedLeague3);
}
}
async function associateSportsSeasonWithLeague() {
const relatedLeague0 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsSeason0 = await SportsSeasons.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SportsSeason0?.setLeague)
{
await
SportsSeason0.
setLeague(relatedLeague0);
}
const relatedLeague1 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsSeason1 = await SportsSeasons.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SportsSeason1?.setLeague)
{
await
SportsSeason1.
setLeague(relatedLeague1);
}
const relatedLeague2 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsSeason2 = await SportsSeasons.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SportsSeason2?.setLeague)
{
await
SportsSeason2.
setLeague(relatedLeague2);
}
const relatedLeague3 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsSeason3 = await SportsSeasons.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SportsSeason3?.setLeague)
{
await
SportsSeason3.
setLeague(relatedLeague3);
}
}
async function associateMatcheWithLeague() {
const relatedLeague0 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setLeague)
{
await
Matche0.
setLeague(relatedLeague0);
}
const relatedLeague1 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setLeague)
{
await
Matche1.
setLeague(relatedLeague1);
}
const relatedLeague2 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setLeague)
{
await
Matche2.
setLeague(relatedLeague2);
}
const relatedLeague3 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setLeague)
{
await
Matche3.
setLeague(relatedLeague3);
}
}
async function associateMatcheWithSeason() {
const relatedSeason0 = await SportsSeasons.findOne({
offset: Math.floor(Math.random() * (await SportsSeasons.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setSeason)
{
await
Matche0.
setSeason(relatedSeason0);
}
const relatedSeason1 = await SportsSeasons.findOne({
offset: Math.floor(Math.random() * (await SportsSeasons.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setSeason)
{
await
Matche1.
setSeason(relatedSeason1);
}
const relatedSeason2 = await SportsSeasons.findOne({
offset: Math.floor(Math.random() * (await SportsSeasons.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setSeason)
{
await
Matche2.
setSeason(relatedSeason2);
}
const relatedSeason3 = await SportsSeasons.findOne({
offset: Math.floor(Math.random() * (await SportsSeasons.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setSeason)
{
await
Matche3.
setSeason(relatedSeason3);
}
}
async function associateMatcheWithHome_team() {
const relatedHome_team0 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setHome_team)
{
await
Matche0.
setHome_team(relatedHome_team0);
}
const relatedHome_team1 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setHome_team)
{
await
Matche1.
setHome_team(relatedHome_team1);
}
const relatedHome_team2 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setHome_team)
{
await
Matche2.
setHome_team(relatedHome_team2);
}
const relatedHome_team3 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setHome_team)
{
await
Matche3.
setHome_team(relatedHome_team3);
}
}
async function associateMatcheWithAway_team() {
const relatedAway_team0 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setAway_team)
{
await
Matche0.
setAway_team(relatedAway_team0);
}
const relatedAway_team1 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setAway_team)
{
await
Matche1.
setAway_team(relatedAway_team1);
}
const relatedAway_team2 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setAway_team)
{
await
Matche2.
setAway_team(relatedAway_team2);
}
const relatedAway_team3 = await SportsTeams.findOne({
offset: Math.floor(Math.random() * (await SportsTeams.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setAway_team)
{
await
Matche3.
setAway_team(relatedAway_team3);
}
}
async function associateMatcheWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setVenue)
{
await
Matche0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setVenue)
{
await
Matche1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setVenue)
{
await
Matche2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setVenue)
{
await
Matche3.
setVenue(relatedVenue3);
}
}
async function associateMatcheWithHighlights_video() {
const relatedHighlights_video0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setHighlights_video)
{
await
Matche0.
setHighlights_video(relatedHighlights_video0);
}
const relatedHighlights_video1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setHighlights_video)
{
await
Matche1.
setHighlights_video(relatedHighlights_video1);
}
const relatedHighlights_video2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setHighlights_video)
{
await
Matche2.
setHighlights_video(relatedHighlights_video2);
}
const relatedHighlights_video3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setHighlights_video)
{
await
Matche3.
setHighlights_video(relatedHighlights_video3);
}
}
async function associateMatcheWithFull_match_video() {
const relatedFull_match_video0 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setFull_match_video)
{
await
Matche0.
setFull_match_video(relatedFull_match_video0);
}
const relatedFull_match_video1 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setFull_match_video)
{
await
Matche1.
setFull_match_video(relatedFull_match_video1);
}
const relatedFull_match_video2 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setFull_match_video)
{
await
Matche2.
setFull_match_video(relatedFull_match_video2);
}
const relatedFull_match_video3 = await Videos.findOne({
offset: Math.floor(Math.random() * (await Videos.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setFull_match_video)
{
await
Matche3.
setFull_match_video(relatedFull_match_video3);
}
}
async function associateMatchEventWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent0 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchEvent0?.setMatch)
{
await
MatchEvent0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent1 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchEvent1?.setMatch)
{
await
MatchEvent1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent2 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchEvent2?.setMatch)
{
await
MatchEvent2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent3 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchEvent3?.setMatch)
{
await
MatchEvent3.
setMatch(relatedMatch3);
}
}
async function associateSportsArticleWithLeague() {
const relatedLeague0 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsArticle0 = await SportsArticles.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SportsArticle0?.setLeague)
{
await
SportsArticle0.
setLeague(relatedLeague0);
}
const relatedLeague1 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsArticle1 = await SportsArticles.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SportsArticle1?.setLeague)
{
await
SportsArticle1.
setLeague(relatedLeague1);
}
const relatedLeague2 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsArticle2 = await SportsArticles.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SportsArticle2?.setLeague)
{
await
SportsArticle2.
setLeague(relatedLeague2);
}
const relatedLeague3 = await SportsLeagues.findOne({
offset: Math.floor(Math.random() * (await SportsLeagues.count())),
});
const SportsArticle3 = await SportsArticles.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SportsArticle3?.setLeague)
{
await
SportsArticle3.
setLeague(relatedLeague3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Profiles.bulkCreate(ProfilesData);
await Subscriptions.bulkCreate(SubscriptionsData);
await Genres.bulkCreate(GenresData);
await ContentCollections.bulkCreate(ContentCollectionsData);
await Videos.bulkCreate(VideosData);
await Titles.bulkCreate(TitlesData);
await Seasons.bulkCreate(SeasonsData);
await Episodes.bulkCreate(EpisodesData);
await WatchProgress.bulkCreate(WatchProgressData);
await MyListItems.bulkCreate(MyListItemsData);
await Reviews.bulkCreate(ReviewsData);
await SportsLeagues.bulkCreate(SportsLeaguesData);
await SportsTeams.bulkCreate(SportsTeamsData);
await SportsSeasons.bulkCreate(SportsSeasonsData);
await Venues.bulkCreate(VenuesData);
await Matches.bulkCreate(MatchesData);
await MatchEvents.bulkCreate(MatchEventsData);
await SportsArticles.bulkCreate(SportsArticlesData);
await Promise.all([
// Similar logic for "relation_many"
await associateProfileWithUser(),
await associateSubscriptionWithUser(),
// Similar logic for "relation_many"
// Similar logic for "relation_many"
await associateTitleWithPrimary_trailer(),
await associateSeasonWithTitle(),
await associateEpisodeWithSeason(),
await associateEpisodeWithPlayback_video(),
await associateEpisodeWithTrailer_video(),
await associateWatchProgresWithUser(),
await associateWatchProgresWithVideo(),
await associateMyListItemWithUser(),
await associateMyListItemWithTitle(),
await associateReviewWithUser(),
await associateReviewWithTitle(),
await associateSportsTeamWithLeague(),
await associateSportsSeasonWithLeague(),
await associateMatcheWithLeague(),
await associateMatcheWithSeason(),
await associateMatcheWithHome_team(),
await associateMatcheWithAway_team(),
await associateMatcheWithVenue(),
await associateMatcheWithHighlights_video(),
await associateMatcheWithFull_match_video(),
await associateMatchEventWithMatch(),
await associateSportsArticleWithLeague(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('profiles', null, {});
await queryInterface.bulkDelete('subscriptions', null, {});
await queryInterface.bulkDelete('genres', null, {});
await queryInterface.bulkDelete('content_collections', null, {});
await queryInterface.bulkDelete('videos', null, {});
await queryInterface.bulkDelete('titles', null, {});
await queryInterface.bulkDelete('seasons', null, {});
await queryInterface.bulkDelete('episodes', null, {});
await queryInterface.bulkDelete('watch_progress', null, {});
await queryInterface.bulkDelete('my_list_items', null, {});
await queryInterface.bulkDelete('reviews', null, {});
await queryInterface.bulkDelete('sports_leagues', null, {});
await queryInterface.bulkDelete('sports_teams', null, {});
await queryInterface.bulkDelete('sports_seasons', null, {});
await queryInterface.bulkDelete('venues', null, {});
await queryInterface.bulkDelete('matches', null, {});
await queryInterface.bulkDelete('match_events', null, {});
await queryInterface.bulkDelete('sports_articles', null, {});
},
};