62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
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: '09:30',
|
|
latest_time: '22: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);
|
|
});
|
|
};
|