-
Notifications
You must be signed in to change notification settings - Fork 0
/
20230527122735-users.js
67 lines (61 loc) · 1.56 KB
/
20230527122735-users.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"use strict";
const bcrypt = require("bcrypt");
const saltRounds = 10;
const users = [
{
username: "sarahedo",
password: bcrypt.hashSync("password123", saltRounds),
firstName: "Sarah",
lastName: "Edo",
avatar: "https://i.pravatar.cc/250?img=47",
},
{
username: "tylermcginnis",
password: bcrypt.hashSync("abc321", saltRounds),
firstName: "Tyler",
lastName: "McGinnis",
avatar: "https://i.pravatar.cc/250?img=67",
},
{
username: "mtsamis",
password: bcrypt.hashSync("xyz123", saltRounds),
firstName: "Mike",
lastName: "Tsamis",
avatar: "https://i.pravatar.cc/250?img=59",
},
{
username: "zoshikanlu",
password: bcrypt.hashSync("pass246", saltRounds),
firstName: "Zenobia",
lastName: "Oshikanlu",
avatar: "https://i.pravatar.cc/250?img=49",
},
];
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
/**
* Add seed commands here.
*
* Example:
* await queryInterface.bulkInsert('People', [{
* name: 'John Doe',
* isBetaMember: false
* }], {});
*/
if ((await queryInterface.select(null, "users")).length) {
console.log(">> Table is not empty, skip seeding.");
return;
}
await queryInterface.bulkInsert("users", users, {});
},
async down(queryInterface, Sequelize) {
/**
* Add commands to revert seed here.
*
* Example:
* await queryInterface.bulkDelete('People', null, {});
*/
await queryInterface.bulkDelete("users", null, {});
},
};