fix: seed user data column name (#87)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/** @type {import('sequelize-cli').Migration} */
|
/** @type {import('sequelize-cli').Migration} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
async up (queryInterface, Sequelize) {
|
async up(queryInterface, Sequelize) {
|
||||||
/**
|
/**
|
||||||
* Add altering commands here.
|
* Add altering commands here.
|
||||||
*
|
*
|
||||||
@@ -15,12 +15,12 @@ module.exports = {
|
|||||||
await queryInterface.renameColumn('users', 'avatarPath', 'avatar_path');
|
await queryInterface.renameColumn('users', 'avatarPath', 'avatar_path');
|
||||||
},
|
},
|
||||||
|
|
||||||
async down (queryInterface, Sequelize) {
|
async down(queryInterface, Sequelize) {
|
||||||
/**
|
/**
|
||||||
* Add reverting commands here.
|
* Add reverting commands here.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* await queryInterface.dropTable('users');
|
* await queryInterface.dropTable('users');
|
||||||
*/
|
*/
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,28 +5,32 @@
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function defineUser(sequelize, DataTypes) {
|
function defineUser(sequelize, DataTypes) {
|
||||||
const User = sequelize.define('User', {
|
const User = sequelize.define(
|
||||||
email: {
|
'User',
|
||||||
type: DataTypes.STRING,
|
{
|
||||||
allowNull: false,
|
email: {
|
||||||
unique: true,
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
unique: true,
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
role: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
avatarPath: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
password: {
|
{ underscored: true }
|
||||||
type: DataTypes.STRING,
|
);
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
username: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
role: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
avatarPath: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
}, { underscored: true });
|
|
||||||
|
|
||||||
User.associate = (models) => {
|
User.associate = (models) => {
|
||||||
User.hasMany(models.Project, { foreignKey: 'userId' });
|
User.hasMany(models.Project, { foreignKey: 'userId' });
|
||||||
|
|||||||
@@ -13,72 +13,72 @@ module.exports = {
|
|||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Admin',
|
username: 'Admin',
|
||||||
role: 0,
|
role: 0,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'samuel@example.com',
|
email: 'samuel@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Samuel Golden',
|
username: 'Samuel Golden',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'trey@example.com',
|
email: 'trey@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Trey Fisher',
|
username: 'Trey Fisher',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'zoe@example.com',
|
email: 'zoe@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Zoe Woodward',
|
username: 'Zoe Woodward',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'roger@example.com',
|
email: 'roger@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Roger Hess',
|
username: 'Roger Hess',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'jasmine@example.com',
|
email: 'jasmine@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Jasmine Moody',
|
username: 'Jasmine Moody',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'tatsuya@example.com',
|
email: 'tatsuya@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Suzuki Tatsuya',
|
username: 'Suzuki Tatsuya',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: 'eri@example.com',
|
email: 'eri@example.com',
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
username: 'Sato Eri',
|
username: 'Sato Eri',
|
||||||
role: 1,
|
role: 1,
|
||||||
avatarPath: null,
|
avatar_path: null,
|
||||||
createdAt: new Date(),
|
created_at: new Date(),
|
||||||
updatedAt: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user