125 lines
2.9 KiB
JavaScript
125 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
await queryInterface.createTable('bank_employees', {
|
|
id: {
|
|
allowNull: false,
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
type: Sequelize.INTEGER
|
|
},
|
|
employeeNumber: {
|
|
type: Sequelize.STRING(20),
|
|
allowNull: false,
|
|
unique: true,
|
|
comment: '员工编号'
|
|
},
|
|
name: {
|
|
type: Sequelize.STRING(50),
|
|
allowNull: false,
|
|
comment: '员工姓名'
|
|
},
|
|
phone: {
|
|
type: Sequelize.STRING(20),
|
|
allowNull: false,
|
|
comment: '联系电话'
|
|
},
|
|
email: {
|
|
type: Sequelize.STRING(100),
|
|
allowNull: true,
|
|
comment: '邮箱'
|
|
},
|
|
password: {
|
|
type: Sequelize.STRING(255),
|
|
allowNull: false,
|
|
comment: '密码'
|
|
},
|
|
isLoanSpecialist: {
|
|
type: Sequelize.BOOLEAN,
|
|
defaultValue: false,
|
|
comment: '是否为贷款专员'
|
|
},
|
|
department: {
|
|
type: Sequelize.STRING(50),
|
|
allowNull: true,
|
|
comment: '部门'
|
|
},
|
|
position: {
|
|
type: Sequelize.STRING(50),
|
|
allowNull: true,
|
|
comment: '职位'
|
|
},
|
|
status: {
|
|
type: Sequelize.ENUM('active', 'inactive', 'locked'),
|
|
defaultValue: 'active',
|
|
comment: '账号状态'
|
|
},
|
|
lastLogin: {
|
|
type: Sequelize.DATE,
|
|
allowNull: true,
|
|
comment: '最后登录时间'
|
|
},
|
|
loginAttempts: {
|
|
type: Sequelize.INTEGER,
|
|
defaultValue: 0,
|
|
comment: '登录尝试次数'
|
|
},
|
|
lockedUntil: {
|
|
type: Sequelize.DATE,
|
|
allowNull: true,
|
|
comment: '锁定到期时间'
|
|
},
|
|
createdBy: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: true,
|
|
comment: '创建人ID'
|
|
},
|
|
updatedBy: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: true,
|
|
comment: '更新人ID'
|
|
},
|
|
createdAt: {
|
|
allowNull: false,
|
|
type: Sequelize.DATE
|
|
},
|
|
updatedAt: {
|
|
allowNull: false,
|
|
type: Sequelize.DATE
|
|
},
|
|
deletedAt: {
|
|
type: Sequelize.DATE,
|
|
allowNull: true
|
|
}
|
|
});
|
|
|
|
// 添加索引
|
|
await queryInterface.addIndex('bank_employees', ['employeeNumber'], {
|
|
unique: true,
|
|
name: 'idx_employees_employee_number'
|
|
});
|
|
|
|
await queryInterface.addIndex('bank_employees', ['phone'], {
|
|
unique: true,
|
|
name: 'idx_employees_phone'
|
|
});
|
|
|
|
await queryInterface.addIndex('bank_employees', ['status'], {
|
|
name: 'idx_employees_status'
|
|
});
|
|
|
|
await queryInterface.addIndex('bank_employees', ['isLoanSpecialist'], {
|
|
name: 'idx_employees_loan_specialist'
|
|
});
|
|
|
|
await queryInterface.addIndex('bank_employees', ['deletedAt'], {
|
|
name: 'idx_employees_deleted_at'
|
|
});
|
|
},
|
|
|
|
async down(queryInterface, Sequelize) {
|
|
await queryInterface.dropTable('bank_employees');
|
|
}
|
|
};
|