const bcrypt = require('bcryptjs'); const { saltingRounds } = require('../../config/config'); exports.seed = function (knex) { // Deletes ALL existing entries return knex('account') .del() .then(function () { const accountSeeds = [ { username: 'liza', email: 'liza@example.com', password: 'password', timezone: 'Europe/Brussels', earliest_time: '00:00', latest_time: '24:00', }, { username: 'emile', email: 'emile@example.com', password: 'password', timezone: 'America/New_York', earliest_time: '09:00', latest_time: '20:00', }, { username: 'jack', email: 'jack@example.com', password: 'password', timezone: 'Asia/Kolkata', earliest_time: '10:30', latest_time: '17:00', }, { username: 'cynthia', email: 'cynthia@example.com', password: 'password', timezone: 'Europe/Brussels', earliest_time: '06:30', latest_time: '12:00', }, { username: 'celine', email: 'celine@example.com', password: 'password', timezone: 'Europe/Brussels', earliest_time: '10:30', latest_time: '20:00', }, ]; // Hash password for each user accountSeeds.forEach((account) => { let hash = bcrypt.hashSync(account.password, saltingRounds); account.password = hash; }); // Inserts seed entries return knex('account').insert(accountSeeds); }); };