122 lines
3.0 KiB
JavaScript
122 lines
3.0 KiB
JavaScript
|
|
'use strict';
|
|||
|
|
|
|||
|
|
module.exports = {
|
|||
|
|
async up(queryInterface, Sequelize) {
|
|||
|
|
await queryInterface.createTable('projects', {
|
|||
|
|
id: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
primaryKey: true,
|
|||
|
|
autoIncrement: true,
|
|||
|
|
allowNull: false
|
|||
|
|
},
|
|||
|
|
name: {
|
|||
|
|
type: Sequelize.STRING(100),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '项目名称'
|
|||
|
|
},
|
|||
|
|
status: {
|
|||
|
|
type: Sequelize.ENUM('supervision', 'completed'),
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 'supervision',
|
|||
|
|
comment: '项目状态:supervision-监管中,completed-已结项'
|
|||
|
|
},
|
|||
|
|
farmName: {
|
|||
|
|
type: Sequelize.STRING(200),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '养殖场名称'
|
|||
|
|
},
|
|||
|
|
supervisionObject: {
|
|||
|
|
type: Sequelize.STRING(50),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '监管对象'
|
|||
|
|
},
|
|||
|
|
supervisionQuantity: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '监管数量'
|
|||
|
|
},
|
|||
|
|
supervisionPeriod: {
|
|||
|
|
type: Sequelize.STRING(50),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '监管周期'
|
|||
|
|
},
|
|||
|
|
supervisionAmount: {
|
|||
|
|
type: Sequelize.DECIMAL(15, 2),
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0.00,
|
|||
|
|
comment: '监管金额'
|
|||
|
|
},
|
|||
|
|
startTime: {
|
|||
|
|
type: Sequelize.DATEONLY,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '起始时间'
|
|||
|
|
},
|
|||
|
|
endTime: {
|
|||
|
|
type: Sequelize.DATEONLY,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '结束时间'
|
|||
|
|
},
|
|||
|
|
earTag: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '耳标数量'
|
|||
|
|
},
|
|||
|
|
collar: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '项圈数量'
|
|||
|
|
},
|
|||
|
|
host: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '主机数量'
|
|||
|
|
},
|
|||
|
|
loanOfficer: {
|
|||
|
|
type: Sequelize.STRING(100),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '贷款专员'
|
|||
|
|
},
|
|||
|
|
description: {
|
|||
|
|
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.NOW
|
|||
|
|
},
|
|||
|
|
updatedAt: {
|
|||
|
|
type: Sequelize.DATE,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: Sequelize.NOW
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 添加索引
|
|||
|
|
await queryInterface.addIndex('projects', ['status']);
|
|||
|
|
await queryInterface.addIndex('projects', ['farmName']);
|
|||
|
|
await queryInterface.addIndex('projects', ['createdBy']);
|
|||
|
|
await queryInterface.addIndex('projects', ['startTime']);
|
|||
|
|
await queryInterface.addIndex('projects', ['endTime']);
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
async down(queryInterface, Sequelize) {
|
|||
|
|
await queryInterface.dropTable('projects');
|
|||
|
|
}
|
|||
|
|
};
|