bullpen/backend/seeders/02-users-development.js

33 lines
1.8 KiB
JavaScript

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 !== 'development') return;
const roles = await queryInterface.select(null, 'Roles');
const players = [
{ email: 'ryan.nolan@bullpen.com', password: 'ryan$123', firstName: 'Nolan', lastName: 'Ryan', dateOfBirth: new Date(1947, 0, 31), jerseyNumber: 17, gender: 'male', bats: 'right', throws: 'right', state: 'active' },
{ email: 'sandy.koufax@bullpen.com', password: 'sandy$123', firstName: 'Sandy', lastName: 'Koufax', dateOfBirth: new Date(1935, 11, 30), jerseyNumber: 18, gender: 'male', bats: 'right', throws: 'right', state: 'active' },
{ email: 'pedro.martinez@bullpen.com', password: 'pedro$123', firstName: 'Pedro', lastName: 'Martinez', dateOfBirth: new Date(1971, 9, 25), jerseyNumber: 19, gender: 'male', bats: 'right', throws: 'right', state: 'active' },
{ email: 'randy.johnson@bullpen.com', password: 'randy$123', firstName: 'Randy', lastName: 'Johnson', dateOfBirth: new Date(1963, 8, 10), jerseyNumber: 20, gender: 'male', bats: 'right', throws: 'right', state: 'active' },
];
await createPlayer(queryInterface, roles, players);
await createUsers(queryInterface, roles, [
{ email: 'sparky.anderson@bullpen.com', password: 'sparky$123', firstName: 'Sparky', lastName: 'Anderson', dateOfBirth: new Date(1934, 1, 22), roles: ['coach', 'admin'] },
]);
},
async down (queryInterface, /*Sequelize*/) {
if (process.env.NODE_ENV !== 'development') return;
await queryInterface.dropTable('Authentications');
await queryInterface.dropTable('Users');
await queryInterface.dropTable('UserRoles');
await queryInterface.dropTable('Players');
}
};