31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
const bcrypt = require("bcryptjs");
|
|
const process = require('process');
|
|
const {createPlayer, createUsers} = require("../helper/seeder.helper");
|
|
|
|
/** @type {import('sequelize-cli').Migration} */
|
|
module.exports = {
|
|
async up (queryInterface, /*Sequelize*/) {
|
|
if (process.env.NODE_ENV !== 'production') return;
|
|
|
|
const roles = await queryInterface.select(null, 'Roles');
|
|
const players = [
|
|
{ email: 'kuehl.julian@gmail.com', password: 'julian$123', firstName: 'Julian', lastName: 'Kühl', dateOfBirth: new Date(2009, 8, 8), gender: 'male', jerseyNumber: 75, bats: 'right', throws: 'right', state: 'active' },
|
|
];
|
|
|
|
await createPlayer(queryInterface, roles, players);
|
|
await createUsers(queryInterface, roles, [
|
|
{ email: 'cichocki.c@gmail.com', password: 'clemens$123', firstName: 'Clemens', lastName: 'Cichocki', dateOfBirth: new Date(1970, 1, 1), roles: ['coach'] },
|
|
{ email: 'admin@example.com', password: 'admin$123', firstName: 'Admin', lastName: 'Bullpen', dateOfBirth: new Date(1970, 1, 1), roles: ['admin'] },
|
|
]);
|
|
},
|
|
|
|
async down (queryInterface, /*Sequelize*/) {
|
|
if (process.env.NODE_ENV !== 'production') return;
|
|
|
|
await queryInterface.dropTable('Authentications');
|
|
await queryInterface.dropTable('Users');
|
|
await queryInterface.dropTable('UserRoles');
|
|
await queryInterface.dropTable('Players');
|
|
}
|
|
};
|