Files
nxxmdata/bank-backend/migrations/20241220000003-create-supervision-tasks.js

153 lines
4.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('supervision_tasks', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false
},
applicationNumber: {
type: Sequelize.STRING(50),
allowNull: false,
unique: true,
comment: '申请单号'
},
contractNumber: {
type: Sequelize.STRING(50),
allowNull: false,
unique: true,
comment: '放款合同编号'
},
productName: {
type: Sequelize.STRING(100),
allowNull: false,
comment: '产品名称'
},
customerName: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '客户姓名'
},
idType: {
type: Sequelize.ENUM('id_card', 'passport', 'other'),
allowNull: false,
defaultValue: 'id_card',
comment: '证件类型id_card-身份证passport-护照other-其他'
},
idNumber: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '证件号码'
},
assetType: {
type: Sequelize.ENUM('cattle', 'sheep', 'pig', 'poultry', 'other'),
allowNull: false,
defaultValue: 'cattle',
comment: '养殖生资种类cattle-牛sheep-羊pig-猪poultry-家禽other-其他'
},
assetQuantity: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '监管生资数量'
},
supervisionStatus: {
type: Sequelize.ENUM('pending', 'supervising', 'completed', 'suspended'),
allowNull: false,
defaultValue: 'pending',
comment: '监管状态pending-待监管supervising-监管中completed-已完成suspended-已暂停'
},
importTime: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '任务导入时间'
},
startTime: {
type: Sequelize.DATEONLY,
allowNull: false,
comment: '监管起始时间'
},
endTime: {
type: Sequelize.DATEONLY,
allowNull: false,
comment: '监管结束时间'
},
loanAmount: {
type: Sequelize.DECIMAL(15, 2),
allowNull: true,
defaultValue: 0.00,
comment: '贷款金额'
},
interestRate: {
type: Sequelize.DECIMAL(5, 4),
allowNull: true,
defaultValue: 0.0000,
comment: '利率'
},
loanTerm: {
type: Sequelize.INTEGER,
allowNull: true,
defaultValue: 12,
comment: '贷款期限(月)'
},
supervisorName: {
type: Sequelize.STRING(50),
allowNull: true,
comment: '监管员姓名'
},
supervisorPhone: {
type: Sequelize.STRING(20),
allowNull: true,
comment: '监管员电话'
},
farmAddress: {
type: Sequelize.STRING(200),
allowNull: true,
comment: '养殖场地址'
},
remarks: {
type: Sequelize.TEXT,
allowNull: true,
comment: '备注'
},
createdBy: {
type: Sequelize.INTEGER,
allowNull: true,
comment: '创建人ID'
},
updatedBy: {
type: Sequelize.INTEGER,
allowNull: true,
comment: '更新人ID'
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
});
// 添加索引
await queryInterface.addIndex('supervision_tasks', ['applicationNumber']);
await queryInterface.addIndex('supervision_tasks', ['contractNumber']);
await queryInterface.addIndex('supervision_tasks', ['customerName']);
await queryInterface.addIndex('supervision_tasks', ['supervisionStatus']);
await queryInterface.addIndex('supervision_tasks', ['createdBy']);
await queryInterface.addIndex('supervision_tasks', ['startTime']);
await queryInterface.addIndex('supervision_tasks', ['endTime']);
},
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('supervision_tasks');
}
};