38268-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-07 12:27:53 +00:00

3443 lines
65 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const PokemonSpecies = db.pokemon_species;
const PokemonForms = db.pokemon_forms;
const Games = db.games;
const Dexes = db.dexes;
const DexEntries = db.dex_entries;
const ShinyLockRules = db.shiny_lock_rules;
const UserGames = db.user_games;
const DexProgress = db.dex_progress;
const PokemonSpeciesData = [
{
"national_dex_number": 1,
"name": "Bulbasaur",
"genus": "Seed Pokemon",
"primary_type": "ghost",
"secondary_type": "none",
"description": "A strange seed was planted on its back at birth. The plant sprouts and grows with this Pokemon.",
// type code here for "images" field
// type code here for "images" field
},
{
"national_dex_number": 4,
"name": "Charmander",
"genus": "Lizard Pokemon",
"primary_type": "bug",
"secondary_type": "fire",
"description": "It has a preference for hot things. When it rains, steam is said to spout from the tip of its tail.",
// type code here for "images" field
// type code here for "images" field
},
{
"national_dex_number": 7,
"name": "Squirtle",
"genus": "Tiny Turtle Pokemon",
"primary_type": "fighting",
"secondary_type": "flying",
"description": "When it retracts its long neck into its shell, it squirts out water with vigorous force.",
// type code here for "images" field
// type code here for "images" field
},
{
"national_dex_number": 25,
"name": "Pikachu",
"genus": "Mouse Pokemon",
"primary_type": "fire",
"secondary_type": "ice",
"description": "It keeps its tail raised to monitor its surroundings. If you yank its tail, it will try to bite you.",
// type code here for "images" field
// type code here for "images" field
},
{
"national_dex_number": 150,
"name": "Mewtwo",
"genus": "Genetic Pokemon",
"primary_type": "ground",
"secondary_type": "none",
"description": "It was created by a scientist after years of horrific gene splicing and DNA engineering experiments.",
// type code here for "images" field
// type code here for "images" field
},
];
const PokemonFormsData = [
{
// type code here for "relation_one" field
"form_name": "Bulbasaur",
"form_category": "standard",
"is_default_form": true,
"primary_type_override": "fighting",
"secondary_type_override": "fairy",
// type code here for "images" field
// type code here for "images" field
},
{
// type code here for "relation_one" field
"form_name": "Charmander",
"form_category": "special",
"is_default_form": true,
"primary_type_override": "grass",
"secondary_type_override": "inherit",
// type code here for "images" field
// type code here for "images" field
},
{
// type code here for "relation_one" field
"form_name": "Squirtle",
"form_category": "standard",
"is_default_form": true,
"primary_type_override": "ground",
"secondary_type_override": "fighting",
// type code here for "images" field
// type code here for "images" field
},
{
// type code here for "relation_one" field
"form_name": "Pikachu",
"form_category": "regional",
"is_default_form": true,
"primary_type_override": "psychic",
"secondary_type_override": "water",
// type code here for "images" field
// type code here for "images" field
},
{
// type code here for "relation_one" field
"form_name": "Mewtwo",
"form_category": "mega",
"is_default_form": true,
"primary_type_override": "fighting",
"secondary_type_override": "rock",
// type code here for "images" field
// type code here for "images" field
},
];
const GamesData = [
{
"title": "Pokemon Red",
"generation": "gen9",
"platform": "ds",
"release_date": new Date('1998-09-28T00:00:00Z'),
"region": "Kanto",
// type code here for "images" field
"is_main_series": true,
},
{
"title": "Pokemon Blue",
"generation": "gen7",
"platform": "ds",
"release_date": new Date('1998-09-28T00:00:00Z'),
"region": "Kanto",
// type code here for "images" field
"is_main_series": true,
},
{
"title": "Pokemon Crystal",
"generation": "gen1",
"platform": "mobile",
"release_date": new Date('2001-07-29T00:00:00Z'),
"region": "Johto",
// type code here for "images" field
"is_main_series": true,
},
{
"title": "Pokemon Emerald",
"generation": "gen3",
"platform": "pc",
"release_date": new Date('2005-05-01T00:00:00Z'),
"region": "Hoenn",
// type code here for "images" field
"is_main_series": true,
},
{
"title": "Pokemon Sword",
"generation": "gen1",
"platform": "gba",
"release_date": new Date('2019-11-15T00:00:00Z'),
"region": "Galar",
// type code here for "images" field
"is_main_series": true,
},
];
const DexesData = [
{
// type code here for "relation_one" field
"name": "Kanto Pokedex",
"dex_kind": "national",
"notes": "Regional dex for the Kanto adventure.",
},
{
// type code here for "relation_one" field
"name": "Kanto Pokedex",
"dex_kind": "regional",
"notes": "Regional dex for the Kanto adventure.",
},
{
// type code here for "relation_one" field
"name": "Johto Pokedex",
"dex_kind": "national",
"notes": "Regional dex for the Johto journey.",
},
{
// type code here for "relation_one" field
"name": "Hoenn Pokedex",
"dex_kind": "regional",
"notes": "Regional dex for the Hoenn region, focused on local species.",
},
{
// type code here for "relation_one" field
"name": "Galar Pokedex",
"dex_kind": "dlc",
"notes": "Regional dex for the Galar region including Wild Area entries.",
},
];
const DexEntriesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"dex_number": 1,
"availability": "unobtainable",
"is_mythical": false,
"is_legendary": false,
"location_hint": "Starter choice in Pallet Town.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"dex_number": 4,
"availability": "version_exclusive",
"is_mythical": false,
"is_legendary": false,
"location_hint": "Starter choice in Pallet Town.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"dex_number": 7,
"availability": "event_only",
"is_mythical": false,
"is_legendary": true,
"location_hint": "Starter choice in Pallet Town.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"dex_number": 25,
"availability": "transfer_only",
"is_mythical": false,
"is_legendary": true,
"location_hint": "Found in Viridian Forest in some versions.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"dex_number": 150,
"availability": "unobtainable",
"is_mythical": false,
"is_legendary": true,
"location_hint": "Endgame encounter in a hidden cave.",
},
];
const ShinyLockRulesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_shiny_locked": false,
"lock_scope": "event",
"reason": "Available as shiny via standard encounter methods.",
"effective_from": new Date('2019-11-15T00:00:00Z'),
"effective_to": new Date('2030-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_shiny_locked": true,
"lock_scope": "static_encounter",
"reason": "Static encounter is shiny locked in this title.",
"effective_from": new Date('2019-11-15T00:00:00Z'),
"effective_to": new Date('2030-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_shiny_locked": true,
"lock_scope": "event",
"reason": "Shiny available with random encounters and breeding.",
"effective_from": new Date('2005-05-01T00:00:00Z'),
"effective_to": new Date('2030-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_shiny_locked": false,
"lock_scope": "event",
"reason": "Shiny available; odds affected by mechanics in this generation.",
"effective_from": new Date('2001-07-29T00:00:00Z'),
"effective_to": new Date('2030-01-01T00:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_shiny_locked": true,
"lock_scope": "gift",
"reason": "Shiny is not obtainable in this generation for this encounter.",
"effective_from": new Date('1998-09-28T00:00:00Z'),
"effective_to": new Date('2001-07-28T00:00:00Z'),
},
];
const UserGamesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"play_status": "dropped",
"started_at": new Date('2026-01-10T00:00:00Z'),
"finished_at": new Date('2026-03-01T00:00:00Z'),
"notes": "Working through gyms and updating dex weekly.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"play_status": "completed",
"started_at": new Date('2025-11-01T00:00:00Z'),
"finished_at": new Date('2025-12-15T00:00:00Z'),
"notes": "Postgame complete; now focusing on dex cleanup.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"play_status": "dropped",
"started_at": new Date('2026-01-05T00:00:00Z'),
"finished_at": new Date('2026-02-20T00:00:00Z'),
"notes": "Prioritizing Johto regional dex before Kanto.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"play_status": "dropped",
"started_at": new Date('2025-10-10T00:00:00Z'),
"finished_at": new Date('2025-10-30T00:00:00Z'),
"notes": "Fast playthrough; starting shiny hunts next.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"play_status": "playing",
"started_at": new Date('2026-02-15T00:00:00Z'),
"finished_at": new Date('2026-04-01T00:00:00Z'),
"notes": "Plan to do version exclusives trading with friends.",
},
];
const DexProgressData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "registered",
"shiny_status": "shiny_caught",
"encounters": 12,
"resets": 0,
"has_marked_shiny_lock_ack": true,
"last_updated_on": new Date('2026-01-21T10:00:00Z'),
"notes": "Starter obtained; evolved plans later.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "seen",
"shiny_status": "gave_up",
"encounters": 145,
"resets": 0,
"has_marked_shiny_lock_ack": false,
"last_updated_on": new Date('2026-01-22T19:20:00Z'),
"notes": "Hunting in early routes; keeping track of encounters.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "unknown",
"shiny_status": "hunting",
"encounters": 0,
"resets": 0,
"has_marked_shiny_lock_ack": false,
"last_updated_on": new Date('2026-01-15T08:05:00Z'),
"notes": "Trade used to complete starter line.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "seen",
"shiny_status": "hunting",
"encounters": 0,
"resets": 0,
"has_marked_shiny_lock_ack": false,
"last_updated_on": new Date('2026-01-18T14:45:00Z'),
"notes": "Registered after evolution; focusing on remaining entries.",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "caught",
"shiny_status": "gave_up",
"encounters": 0,
"resets": 320,
"has_marked_shiny_lock_ack": true,
"last_updated_on": new Date('2026-01-25T16:00:00Z'),
"notes": "Marked as shiny locked for this generation; stopping resets.",
},
];
// Similar logic for "relation_many"
async function associatePokemonFormWithSpecy() {
const relatedSpecy0 = await PokemonSpecies.findOne({
offset: Math.floor(Math.random() * (await PokemonSpecies.count())),
});
const PokemonForm0 = await PokemonForms.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PokemonForm0?.setSpecy)
{
await
PokemonForm0.
setSpecy(relatedSpecy0);
}
const relatedSpecy1 = await PokemonSpecies.findOne({
offset: Math.floor(Math.random() * (await PokemonSpecies.count())),
});
const PokemonForm1 = await PokemonForms.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PokemonForm1?.setSpecy)
{
await
PokemonForm1.
setSpecy(relatedSpecy1);
}
const relatedSpecy2 = await PokemonSpecies.findOne({
offset: Math.floor(Math.random() * (await PokemonSpecies.count())),
});
const PokemonForm2 = await PokemonForms.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PokemonForm2?.setSpecy)
{
await
PokemonForm2.
setSpecy(relatedSpecy2);
}
const relatedSpecy3 = await PokemonSpecies.findOne({
offset: Math.floor(Math.random() * (await PokemonSpecies.count())),
});
const PokemonForm3 = await PokemonForms.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PokemonForm3?.setSpecy)
{
await
PokemonForm3.
setSpecy(relatedSpecy3);
}
const relatedSpecy4 = await PokemonSpecies.findOne({
offset: Math.floor(Math.random() * (await PokemonSpecies.count())),
});
const PokemonForm4 = await PokemonForms.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PokemonForm4?.setSpecy)
{
await
PokemonForm4.
setSpecy(relatedSpecy4);
}
}
async function associateDexeWithGame() {
const relatedGame0 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const Dexe0 = await Dexes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Dexe0?.setGame)
{
await
Dexe0.
setGame(relatedGame0);
}
const relatedGame1 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const Dexe1 = await Dexes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Dexe1?.setGame)
{
await
Dexe1.
setGame(relatedGame1);
}
const relatedGame2 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const Dexe2 = await Dexes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Dexe2?.setGame)
{
await
Dexe2.
setGame(relatedGame2);
}
const relatedGame3 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const Dexe3 = await Dexes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Dexe3?.setGame)
{
await
Dexe3.
setGame(relatedGame3);
}
const relatedGame4 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const Dexe4 = await Dexes.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Dexe4?.setGame)
{
await
Dexe4.
setGame(relatedGame4);
}
}
async function associateDexEntryWithDex() {
const relatedDex0 = await Dexes.findOne({
offset: Math.floor(Math.random() * (await Dexes.count())),
});
const DexEntry0 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DexEntry0?.setDex)
{
await
DexEntry0.
setDex(relatedDex0);
}
const relatedDex1 = await Dexes.findOne({
offset: Math.floor(Math.random() * (await Dexes.count())),
});
const DexEntry1 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DexEntry1?.setDex)
{
await
DexEntry1.
setDex(relatedDex1);
}
const relatedDex2 = await Dexes.findOne({
offset: Math.floor(Math.random() * (await Dexes.count())),
});
const DexEntry2 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DexEntry2?.setDex)
{
await
DexEntry2.
setDex(relatedDex2);
}
const relatedDex3 = await Dexes.findOne({
offset: Math.floor(Math.random() * (await Dexes.count())),
});
const DexEntry3 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DexEntry3?.setDex)
{
await
DexEntry3.
setDex(relatedDex3);
}
const relatedDex4 = await Dexes.findOne({
offset: Math.floor(Math.random() * (await Dexes.count())),
});
const DexEntry4 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DexEntry4?.setDex)
{
await
DexEntry4.
setDex(relatedDex4);
}
}
async function associateDexEntryWithForm() {
const relatedForm0 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const DexEntry0 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DexEntry0?.setForm)
{
await
DexEntry0.
setForm(relatedForm0);
}
const relatedForm1 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const DexEntry1 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DexEntry1?.setForm)
{
await
DexEntry1.
setForm(relatedForm1);
}
const relatedForm2 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const DexEntry2 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DexEntry2?.setForm)
{
await
DexEntry2.
setForm(relatedForm2);
}
const relatedForm3 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const DexEntry3 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DexEntry3?.setForm)
{
await
DexEntry3.
setForm(relatedForm3);
}
const relatedForm4 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const DexEntry4 = await DexEntries.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DexEntry4?.setForm)
{
await
DexEntry4.
setForm(relatedForm4);
}
}
async function associateShinyLockRuleWithGame() {
const relatedGame0 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const ShinyLockRule0 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShinyLockRule0?.setGame)
{
await
ShinyLockRule0.
setGame(relatedGame0);
}
const relatedGame1 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const ShinyLockRule1 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShinyLockRule1?.setGame)
{
await
ShinyLockRule1.
setGame(relatedGame1);
}
const relatedGame2 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const ShinyLockRule2 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShinyLockRule2?.setGame)
{
await
ShinyLockRule2.
setGame(relatedGame2);
}
const relatedGame3 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const ShinyLockRule3 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShinyLockRule3?.setGame)
{
await
ShinyLockRule3.
setGame(relatedGame3);
}
const relatedGame4 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const ShinyLockRule4 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShinyLockRule4?.setGame)
{
await
ShinyLockRule4.
setGame(relatedGame4);
}
}
async function associateShinyLockRuleWithForm() {
const relatedForm0 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const ShinyLockRule0 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShinyLockRule0?.setForm)
{
await
ShinyLockRule0.
setForm(relatedForm0);
}
const relatedForm1 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const ShinyLockRule1 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShinyLockRule1?.setForm)
{
await
ShinyLockRule1.
setForm(relatedForm1);
}
const relatedForm2 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const ShinyLockRule2 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShinyLockRule2?.setForm)
{
await
ShinyLockRule2.
setForm(relatedForm2);
}
const relatedForm3 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const ShinyLockRule3 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShinyLockRule3?.setForm)
{
await
ShinyLockRule3.
setForm(relatedForm3);
}
const relatedForm4 = await PokemonForms.findOne({
offset: Math.floor(Math.random() * (await PokemonForms.count())),
});
const ShinyLockRule4 = await ShinyLockRules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShinyLockRule4?.setForm)
{
await
ShinyLockRule4.
setForm(relatedForm4);
}
}
async function associateUserGameWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserGame0 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UserGame0?.setUser)
{
await
UserGame0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserGame1 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UserGame1?.setUser)
{
await
UserGame1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserGame2 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UserGame2?.setUser)
{
await
UserGame2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserGame3 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UserGame3?.setUser)
{
await
UserGame3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserGame4 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (UserGame4?.setUser)
{
await
UserGame4.
setUser(relatedUser4);
}
}
async function associateUserGameWithGame() {
const relatedGame0 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const UserGame0 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UserGame0?.setGame)
{
await
UserGame0.
setGame(relatedGame0);
}
const relatedGame1 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const UserGame1 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UserGame1?.setGame)
{
await
UserGame1.
setGame(relatedGame1);
}
const relatedGame2 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const UserGame2 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UserGame2?.setGame)
{
await
UserGame2.
setGame(relatedGame2);
}
const relatedGame3 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const UserGame3 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UserGame3?.setGame)
{
await
UserGame3.
setGame(relatedGame3);
}
const relatedGame4 = await Games.findOne({
offset: Math.floor(Math.random() * (await Games.count())),
});
const UserGame4 = await UserGames.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (UserGame4?.setGame)
{
await
UserGame4.
setGame(relatedGame4);
}
}
async function associateDexProgresWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DexProgres0 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DexProgres0?.setUser)
{
await
DexProgres0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DexProgres1 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DexProgres1?.setUser)
{
await
DexProgres1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DexProgres2 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DexProgres2?.setUser)
{
await
DexProgres2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DexProgres3 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DexProgres3?.setUser)
{
await
DexProgres3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DexProgres4 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DexProgres4?.setUser)
{
await
DexProgres4.
setUser(relatedUser4);
}
}
async function associateDexProgresWithDex_entry() {
const relatedDex_entry0 = await DexEntries.findOne({
offset: Math.floor(Math.random() * (await DexEntries.count())),
});
const DexProgres0 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DexProgres0?.setDex_entry)
{
await
DexProgres0.
setDex_entry(relatedDex_entry0);
}
const relatedDex_entry1 = await DexEntries.findOne({
offset: Math.floor(Math.random() * (await DexEntries.count())),
});
const DexProgres1 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DexProgres1?.setDex_entry)
{
await
DexProgres1.
setDex_entry(relatedDex_entry1);
}
const relatedDex_entry2 = await DexEntries.findOne({
offset: Math.floor(Math.random() * (await DexEntries.count())),
});
const DexProgres2 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DexProgres2?.setDex_entry)
{
await
DexProgres2.
setDex_entry(relatedDex_entry2);
}
const relatedDex_entry3 = await DexEntries.findOne({
offset: Math.floor(Math.random() * (await DexEntries.count())),
});
const DexProgres3 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DexProgres3?.setDex_entry)
{
await
DexProgres3.
setDex_entry(relatedDex_entry3);
}
const relatedDex_entry4 = await DexEntries.findOne({
offset: Math.floor(Math.random() * (await DexEntries.count())),
});
const DexProgres4 = await DexProgress.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DexProgres4?.setDex_entry)
{
await
DexProgres4.
setDex_entry(relatedDex_entry4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await PokemonSpecies.bulkCreate(PokemonSpeciesData);
await PokemonForms.bulkCreate(PokemonFormsData);
await Games.bulkCreate(GamesData);
await Dexes.bulkCreate(DexesData);
await DexEntries.bulkCreate(DexEntriesData);
await ShinyLockRules.bulkCreate(ShinyLockRulesData);
await UserGames.bulkCreate(UserGamesData);
await DexProgress.bulkCreate(DexProgressData);
await Promise.all([
// Similar logic for "relation_many"
await associatePokemonFormWithSpecy(),
await associateDexeWithGame(),
await associateDexEntryWithDex(),
await associateDexEntryWithForm(),
await associateShinyLockRuleWithGame(),
await associateShinyLockRuleWithForm(),
await associateUserGameWithUser(),
await associateUserGameWithGame(),
await associateDexProgresWithUser(),
await associateDexProgresWithDex_entry(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('pokemon_species', null, {});
await queryInterface.bulkDelete('pokemon_forms', null, {});
await queryInterface.bulkDelete('games', null, {});
await queryInterface.bulkDelete('dexes', null, {});
await queryInterface.bulkDelete('dex_entries', null, {});
await queryInterface.bulkDelete('shiny_lock_rules', null, {});
await queryInterface.bulkDelete('user_games', null, {});
await queryInterface.bulkDelete('dex_progress', null, {});
},
};