671 lines
16 KiB
JavaScript
671 lines
16 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Customizations = db.customizations;
|
|
|
|
const Games = db.games;
|
|
|
|
const Purchases = db.purchases;
|
|
|
|
const Gather002 = db.gather002;
|
|
|
|
const CustomizationsData = [
|
|
{
|
|
visuals: 'Futuristic Neon',
|
|
|
|
layout: 'Grid',
|
|
|
|
settings: 'High Contrast',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
visuals: 'Mystic Forest',
|
|
|
|
layout: 'Freeform',
|
|
|
|
settings: 'Low Contrast',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
visuals: 'Galactic Theme',
|
|
|
|
layout: 'Circular',
|
|
|
|
settings: 'Medium Contrast',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
visuals: "Dragon's Den",
|
|
|
|
layout: 'Linear',
|
|
|
|
settings: 'High Contrast',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const GamesData = [
|
|
{
|
|
title: 'Epic Adventure',
|
|
|
|
start_date: new Date('2023-11-01T10:00:00Z'),
|
|
|
|
end_date: new Date('2023-11-30T18:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Mystic Quest',
|
|
|
|
start_date: new Date('2023-12-01T09:00:00Z'),
|
|
|
|
end_date: new Date('2023-12-31T17:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: 'Space Odyssey',
|
|
|
|
start_date: new Date('2024-01-01T08:00:00Z'),
|
|
|
|
end_date: new Date('2024-01-31T16:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
title: "Dragon's Lair",
|
|
|
|
start_date: new Date('2024-02-01T07:00:00Z'),
|
|
|
|
end_date: new Date('2024-02-28T15:00:00Z'),
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PurchasesData = [
|
|
{
|
|
amount: 49.99,
|
|
|
|
purchase_date: new Date('2023-11-05T12:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
amount: 29.99,
|
|
|
|
purchase_date: new Date('2023-12-10T13:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
amount: 59.99,
|
|
|
|
purchase_date: new Date('2024-01-15T14:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
amount: 39.99,
|
|
|
|
purchase_date: new Date('2024-02-20T15:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const Gather002Data = [
|
|
{
|
|
name: 'Louis Victor de Broglie',
|
|
},
|
|
|
|
{
|
|
name: 'Rudolf Virchow',
|
|
},
|
|
|
|
{
|
|
name: 'Ernest Rutherford',
|
|
},
|
|
|
|
{
|
|
name: 'John Bardeen',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithGather002() {
|
|
const relatedGather0020 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setGather002) {
|
|
await User0.setGather002(relatedGather0020);
|
|
}
|
|
|
|
const relatedGather0021 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setGather002) {
|
|
await User1.setGather002(relatedGather0021);
|
|
}
|
|
|
|
const relatedGather0022 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setGather002) {
|
|
await User2.setGather002(relatedGather0022);
|
|
}
|
|
|
|
const relatedGather0023 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setGather002) {
|
|
await User3.setGather002(relatedGather0023);
|
|
}
|
|
}
|
|
|
|
async function associateCustomizationWithGame() {
|
|
const relatedGame0 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Customization0 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Customization0?.setGame) {
|
|
await Customization0.setGame(relatedGame0);
|
|
}
|
|
|
|
const relatedGame1 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Customization1 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Customization1?.setGame) {
|
|
await Customization1.setGame(relatedGame1);
|
|
}
|
|
|
|
const relatedGame2 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Customization2 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Customization2?.setGame) {
|
|
await Customization2.setGame(relatedGame2);
|
|
}
|
|
|
|
const relatedGame3 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Customization3 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Customization3?.setGame) {
|
|
await Customization3.setGame(relatedGame3);
|
|
}
|
|
}
|
|
|
|
async function associateCustomizationWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Customization0 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Customization0?.setUser) {
|
|
await Customization0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Customization1 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Customization1?.setUser) {
|
|
await Customization1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Customization2 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Customization2?.setUser) {
|
|
await Customization2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Customization3 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Customization3?.setUser) {
|
|
await Customization3.setUser(relatedUser3);
|
|
}
|
|
}
|
|
|
|
async function associateCustomizationWithGather002() {
|
|
const relatedGather0020 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Customization0 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Customization0?.setGather002) {
|
|
await Customization0.setGather002(relatedGather0020);
|
|
}
|
|
|
|
const relatedGather0021 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Customization1 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Customization1?.setGather002) {
|
|
await Customization1.setGather002(relatedGather0021);
|
|
}
|
|
|
|
const relatedGather0022 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Customization2 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Customization2?.setGather002) {
|
|
await Customization2.setGather002(relatedGather0022);
|
|
}
|
|
|
|
const relatedGather0023 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Customization3 = await Customizations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Customization3?.setGather002) {
|
|
await Customization3.setGather002(relatedGather0023);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateGameWithAdmin() {
|
|
const relatedAdmin0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Game0 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Game0?.setAdmin) {
|
|
await Game0.setAdmin(relatedAdmin0);
|
|
}
|
|
|
|
const relatedAdmin1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Game1 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Game1?.setAdmin) {
|
|
await Game1.setAdmin(relatedAdmin1);
|
|
}
|
|
|
|
const relatedAdmin2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Game2 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Game2?.setAdmin) {
|
|
await Game2.setAdmin(relatedAdmin2);
|
|
}
|
|
|
|
const relatedAdmin3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Game3 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Game3?.setAdmin) {
|
|
await Game3.setAdmin(relatedAdmin3);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateGameWithGather002() {
|
|
const relatedGather0020 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Game0 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Game0?.setGather002) {
|
|
await Game0.setGather002(relatedGather0020);
|
|
}
|
|
|
|
const relatedGather0021 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Game1 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Game1?.setGather002) {
|
|
await Game1.setGather002(relatedGather0021);
|
|
}
|
|
|
|
const relatedGather0022 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Game2 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Game2?.setGather002) {
|
|
await Game2.setGather002(relatedGather0022);
|
|
}
|
|
|
|
const relatedGather0023 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Game3 = await Games.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Game3?.setGather002) {
|
|
await Game3.setGather002(relatedGather0023);
|
|
}
|
|
}
|
|
|
|
async function associatePurchaseWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Purchase0 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Purchase0?.setUser) {
|
|
await Purchase0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Purchase1 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Purchase1?.setUser) {
|
|
await Purchase1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Purchase2 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Purchase2?.setUser) {
|
|
await Purchase2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Purchase3 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Purchase3?.setUser) {
|
|
await Purchase3.setUser(relatedUser3);
|
|
}
|
|
}
|
|
|
|
async function associatePurchaseWithGame() {
|
|
const relatedGame0 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Purchase0 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Purchase0?.setGame) {
|
|
await Purchase0.setGame(relatedGame0);
|
|
}
|
|
|
|
const relatedGame1 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Purchase1 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Purchase1?.setGame) {
|
|
await Purchase1.setGame(relatedGame1);
|
|
}
|
|
|
|
const relatedGame2 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Purchase2 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Purchase2?.setGame) {
|
|
await Purchase2.setGame(relatedGame2);
|
|
}
|
|
|
|
const relatedGame3 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const Purchase3 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Purchase3?.setGame) {
|
|
await Purchase3.setGame(relatedGame3);
|
|
}
|
|
}
|
|
|
|
async function associatePurchaseWithGather002() {
|
|
const relatedGather0020 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Purchase0 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Purchase0?.setGather002) {
|
|
await Purchase0.setGather002(relatedGather0020);
|
|
}
|
|
|
|
const relatedGather0021 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Purchase1 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Purchase1?.setGather002) {
|
|
await Purchase1.setGather002(relatedGather0021);
|
|
}
|
|
|
|
const relatedGather0022 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Purchase2 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Purchase2?.setGather002) {
|
|
await Purchase2.setGather002(relatedGather0022);
|
|
}
|
|
|
|
const relatedGather0023 = await Gather002.findOne({
|
|
offset: Math.floor(Math.random() * (await Gather002.count())),
|
|
});
|
|
const Purchase3 = await Purchases.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Purchase3?.setGather002) {
|
|
await Purchase3.setGather002(relatedGather0023);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Customizations.bulkCreate(CustomizationsData);
|
|
|
|
await Games.bulkCreate(GamesData);
|
|
|
|
await Purchases.bulkCreate(PurchasesData);
|
|
|
|
await Gather002.bulkCreate(Gather002Data);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithGather002(),
|
|
|
|
await associateCustomizationWithGame(),
|
|
|
|
await associateCustomizationWithUser(),
|
|
|
|
await associateCustomizationWithGather002(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateGameWithAdmin(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateGameWithGather002(),
|
|
|
|
await associatePurchaseWithUser(),
|
|
|
|
await associatePurchaseWithGame(),
|
|
|
|
await associatePurchaseWithGather002(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('customizations', null, {});
|
|
|
|
await queryInterface.bulkDelete('games', null, {});
|
|
|
|
await queryInterface.bulkDelete('purchases', null, {});
|
|
|
|
await queryInterface.bulkDelete('gather002', null, {});
|
|
},
|
|
};
|