2020-05-09 12:50:47 +00:00
|
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
const { saltingRounds } = require('../../config/config');
|
|
|
|
|
2020-05-05 15:58:34 +00:00
|
|
|
exports.seed = function (knex) {
|
|
|
|
// Deletes ALL existing entries
|
|
|
|
return knex('account')
|
|
|
|
.del()
|
|
|
|
.then(function () {
|
2020-05-09 12:50:47 +00:00
|
|
|
const accountSeeds = [
|
2020-05-05 15:58:34 +00:00
|
|
|
{
|
|
|
|
username: 'liza',
|
|
|
|
email: 'liza@example.com',
|
2020-08-23 14:04:06 +00:00
|
|
|
password: 'password',
|
2020-05-05 15:58:34 +00:00
|
|
|
timezone: 'Europe/Brussels',
|
|
|
|
earliest_time: '09:30',
|
|
|
|
latest_time: '22:00',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: 'emile',
|
|
|
|
email: 'emile@example.com',
|
2020-08-23 14:04:06 +00:00
|
|
|
password: 'password',
|
2020-05-05 15:58:34 +00:00
|
|
|
timezone: 'America/New_York',
|
|
|
|
earliest_time: '09:00',
|
|
|
|
latest_time: '20:00',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: 'jack',
|
|
|
|
email: 'jack@example.com',
|
2020-08-23 14:04:06 +00:00
|
|
|
password: 'password',
|
2020-05-05 15:58:34 +00:00
|
|
|
timezone: 'Asia/Kolkata',
|
|
|
|
earliest_time: '10:30',
|
|
|
|
latest_time: '17:00',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: 'cynthia',
|
|
|
|
email: 'cynthia@example.com',
|
2020-08-23 14:04:06 +00:00
|
|
|
password: 'password',
|
2020-05-05 15:58:34 +00:00
|
|
|
timezone: 'Europe/Brussels',
|
|
|
|
earliest_time: '06:30',
|
|
|
|
latest_time: '12:00',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: 'celine',
|
|
|
|
email: 'celine@example.com',
|
2020-08-23 14:04:06 +00:00
|
|
|
password: 'password',
|
2020-05-05 15:58:34 +00:00
|
|
|
timezone: 'Europe/Brussels',
|
|
|
|
earliest_time: '10:30',
|
|
|
|
latest_time: '20:00',
|
|
|
|
},
|
2020-05-09 12:50:47 +00: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);
|
2020-05-05 15:58:34 +00:00
|
|
|
});
|
|
|
|
};
|