2020-01-22 01:02:54 +00:00
|
|
|
const {hashPassword} = require('../../services/bcrypt');
|
|
|
|
require('dotenv').config();
|
2020-01-24 05:25:08 +00:00
|
|
|
|
2020-01-22 01:02:54 +00:00
|
|
|
const password = process.env.USER_ONE_PASSWORD;
|
|
|
|
const email = process.env.USER_ONE_EMAIL;
|
|
|
|
|
2020-01-24 05:25:08 +00:00
|
|
|
exports.seed = async function(knex) {
|
2020-01-22 01:02:54 +00:00
|
|
|
// Deletes ALL existing entries
|
|
|
|
return knex('user').del()
|
2020-01-24 05:25:08 +00:00
|
|
|
.then(async function () {
|
|
|
|
const hashedPassword = await hashPassword(password);
|
2020-01-22 01:02:54 +00:00
|
|
|
// Inserts seed entries
|
2020-05-11 00:08:13 +00:00
|
|
|
return knex('user').returning('*').insert([
|
|
|
|
{username: 'user-one', email: email, password: hashedPassword, admin: true},
|
|
|
|
{username: 'user-two', email: `2${email}`, password: hashedPassword, admin: true},
|
|
|
|
]).then(entries => console.log({success: 'user', entries}));
|
2020-01-22 01:02:54 +00:00
|
|
|
});
|
|
|
|
};
|