679 lines
16 KiB
JavaScript
679 lines
16 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Accounts = db.accounts;
|
|
|
|
const Items = db.items;
|
|
|
|
const Transactions = db.transactions;
|
|
|
|
const VipAccounts = db.vip_accounts;
|
|
|
|
const Servidores = db.servidores;
|
|
|
|
const AccountsData = [
|
|
{
|
|
account_name: 'PlayerOne',
|
|
|
|
created_date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'PlayerTwo',
|
|
|
|
created_date: new Date('2023-10-02T11:30:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'PlayerThree',
|
|
|
|
created_date: new Date('2023-10-03T09:15:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'PlayerFour',
|
|
|
|
created_date: new Date('2023-10-04T14:45:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ItemsData = [
|
|
{
|
|
item_name: 'Sword of Valor',
|
|
|
|
quantity: 1,
|
|
|
|
drop_date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
item_name: 'Shield of Courage',
|
|
|
|
quantity: 2,
|
|
|
|
drop_date: new Date('2023-10-02T11:30:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
item_name: 'Helmet of Wisdom',
|
|
|
|
quantity: 1,
|
|
|
|
drop_date: new Date('2023-10-03T09:15:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
item_name: 'Armor of Strength',
|
|
|
|
quantity: 1,
|
|
|
|
drop_date: new Date('2023-10-04T14:45:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const TransactionsData = [
|
|
{
|
|
zeny_amount: 5000,
|
|
|
|
cash_amount: 100,
|
|
|
|
transaction_date: new Date('2023-10-01T12:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
zeny_amount: 7500,
|
|
|
|
cash_amount: 200,
|
|
|
|
transaction_date: new Date('2023-10-02T13:30:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
zeny_amount: 10000,
|
|
|
|
cash_amount: 300,
|
|
|
|
transaction_date: new Date('2023-10-03T15:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
zeny_amount: 15000,
|
|
|
|
cash_amount: 400,
|
|
|
|
transaction_date: new Date('2023-10-04T16:30:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const VipAccountsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
vip_start_date: new Date('2023-10-01T00:00:00Z'),
|
|
|
|
vip_end_date: new Date('2023-11-01T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
vip_start_date: new Date('2023-10-02T00:00:00Z'),
|
|
|
|
vip_end_date: new Date('2023-11-02T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
vip_start_date: new Date('2023-10-03T00:00:00Z'),
|
|
|
|
vip_end_date: new Date('2023-11-03T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
vip_start_date: new Date('2023-10-04T00:00:00Z'),
|
|
|
|
vip_end_date: new Date('2023-11-04T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ServidoresData = [
|
|
{
|
|
name: 'B. F. Skinner',
|
|
},
|
|
|
|
{
|
|
name: 'Leonard Euler',
|
|
},
|
|
|
|
{
|
|
name: 'Isaac Newton',
|
|
},
|
|
|
|
{
|
|
name: 'Willard Libby',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithServidore() {
|
|
const relatedServidore0 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setServidore) {
|
|
await User0.setServidore(relatedServidore0);
|
|
}
|
|
|
|
const relatedServidore1 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setServidore) {
|
|
await User1.setServidore(relatedServidore1);
|
|
}
|
|
|
|
const relatedServidore2 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setServidore) {
|
|
await User2.setServidore(relatedServidore2);
|
|
}
|
|
|
|
const relatedServidore3 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setServidore) {
|
|
await User3.setServidore(relatedServidore3);
|
|
}
|
|
}
|
|
|
|
async function associateAccountWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account0 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Account0?.setUser) {
|
|
await Account0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account1 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Account1?.setUser) {
|
|
await Account1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account2 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Account2?.setUser) {
|
|
await Account2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account3 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Account3?.setUser) {
|
|
await Account3.setUser(relatedUser3);
|
|
}
|
|
}
|
|
|
|
async function associateAccountWithServidore() {
|
|
const relatedServidore0 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Account0 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Account0?.setServidore) {
|
|
await Account0.setServidore(relatedServidore0);
|
|
}
|
|
|
|
const relatedServidore1 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Account1 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Account1?.setServidore) {
|
|
await Account1.setServidore(relatedServidore1);
|
|
}
|
|
|
|
const relatedServidore2 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Account2 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Account2?.setServidore) {
|
|
await Account2.setServidore(relatedServidore2);
|
|
}
|
|
|
|
const relatedServidore3 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Account3 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Account3?.setServidore) {
|
|
await Account3.setServidore(relatedServidore3);
|
|
}
|
|
}
|
|
|
|
async function associateItemWithAccount() {
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Item0 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Item0?.setAccount) {
|
|
await Item0.setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Item1 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Item1?.setAccount) {
|
|
await Item1.setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Item2 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Item2?.setAccount) {
|
|
await Item2.setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Item3 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Item3?.setAccount) {
|
|
await Item3.setAccount(relatedAccount3);
|
|
}
|
|
}
|
|
|
|
async function associateItemWithServidore() {
|
|
const relatedServidore0 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Item0 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Item0?.setServidore) {
|
|
await Item0.setServidore(relatedServidore0);
|
|
}
|
|
|
|
const relatedServidore1 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Item1 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Item1?.setServidore) {
|
|
await Item1.setServidore(relatedServidore1);
|
|
}
|
|
|
|
const relatedServidore2 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Item2 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Item2?.setServidore) {
|
|
await Item2.setServidore(relatedServidore2);
|
|
}
|
|
|
|
const relatedServidore3 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Item3 = await Items.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Item3?.setServidore) {
|
|
await Item3.setServidore(relatedServidore3);
|
|
}
|
|
}
|
|
|
|
async function associateTransactionWithAccount() {
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Transaction0 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Transaction0?.setAccount) {
|
|
await Transaction0.setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Transaction1 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Transaction1?.setAccount) {
|
|
await Transaction1.setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Transaction2 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Transaction2?.setAccount) {
|
|
await Transaction2.setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Transaction3 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Transaction3?.setAccount) {
|
|
await Transaction3.setAccount(relatedAccount3);
|
|
}
|
|
}
|
|
|
|
async function associateTransactionWithServidore() {
|
|
const relatedServidore0 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Transaction0 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Transaction0?.setServidore) {
|
|
await Transaction0.setServidore(relatedServidore0);
|
|
}
|
|
|
|
const relatedServidore1 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Transaction1 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Transaction1?.setServidore) {
|
|
await Transaction1.setServidore(relatedServidore1);
|
|
}
|
|
|
|
const relatedServidore2 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Transaction2 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Transaction2?.setServidore) {
|
|
await Transaction2.setServidore(relatedServidore2);
|
|
}
|
|
|
|
const relatedServidore3 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const Transaction3 = await Transactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Transaction3?.setServidore) {
|
|
await Transaction3.setServidore(relatedServidore3);
|
|
}
|
|
}
|
|
|
|
async function associateVipAccountWithAccount() {
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const VipAccount0 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (VipAccount0?.setAccount) {
|
|
await VipAccount0.setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const VipAccount1 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (VipAccount1?.setAccount) {
|
|
await VipAccount1.setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const VipAccount2 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (VipAccount2?.setAccount) {
|
|
await VipAccount2.setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const VipAccount3 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (VipAccount3?.setAccount) {
|
|
await VipAccount3.setAccount(relatedAccount3);
|
|
}
|
|
}
|
|
|
|
async function associateVipAccountWithServidore() {
|
|
const relatedServidore0 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const VipAccount0 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (VipAccount0?.setServidore) {
|
|
await VipAccount0.setServidore(relatedServidore0);
|
|
}
|
|
|
|
const relatedServidore1 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const VipAccount1 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (VipAccount1?.setServidore) {
|
|
await VipAccount1.setServidore(relatedServidore1);
|
|
}
|
|
|
|
const relatedServidore2 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const VipAccount2 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (VipAccount2?.setServidore) {
|
|
await VipAccount2.setServidore(relatedServidore2);
|
|
}
|
|
|
|
const relatedServidore3 = await Servidores.findOne({
|
|
offset: Math.floor(Math.random() * (await Servidores.count())),
|
|
});
|
|
const VipAccount3 = await VipAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (VipAccount3?.setServidore) {
|
|
await VipAccount3.setServidore(relatedServidore3);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Accounts.bulkCreate(AccountsData);
|
|
|
|
await Items.bulkCreate(ItemsData);
|
|
|
|
await Transactions.bulkCreate(TransactionsData);
|
|
|
|
await VipAccounts.bulkCreate(VipAccountsData);
|
|
|
|
await Servidores.bulkCreate(ServidoresData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithServidore(),
|
|
|
|
await associateAccountWithUser(),
|
|
|
|
await associateAccountWithServidore(),
|
|
|
|
await associateItemWithAccount(),
|
|
|
|
await associateItemWithServidore(),
|
|
|
|
await associateTransactionWithAccount(),
|
|
|
|
await associateTransactionWithServidore(),
|
|
|
|
await associateVipAccountWithAccount(),
|
|
|
|
await associateVipAccountWithServidore(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('accounts', null, {});
|
|
|
|
await queryInterface.bulkDelete('items', null, {});
|
|
|
|
await queryInterface.bulkDelete('transactions', null, {});
|
|
|
|
await queryInterface.bulkDelete('vip_accounts', null, {});
|
|
|
|
await queryInterface.bulkDelete('servidores', null, {});
|
|
},
|
|
};
|