'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.createTable('contacts', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER }, name: { type: Sequelize.STRING(100), allowNull: false, comment: '联系人姓名' }, email: { type: Sequelize.STRING(255), allowNull: false, comment: '联系人邮箱' }, phone: { type: Sequelize.STRING(20), allowNull: true, comment: '联系电话' }, company: { type: Sequelize.STRING(200), allowNull: true, comment: '公司名称' }, subject: { type: Sequelize.STRING(200), allowNull: false, comment: '留言主题' }, message: { type: Sequelize.TEXT, allowNull: false, comment: '留言内容' }, status: { type: Sequelize.INTEGER, defaultValue: 0, comment: '处理状态:0-未处理,1-已处理' }, isEmailSent: { type: Sequelize.BOOLEAN, defaultValue: false, comment: '是否已发送邮件通知' }, createdAt: { allowNull: false, type: Sequelize.DATE }, updatedAt: { allowNull: false, type: Sequelize.DATE } }); // 添加索引 await queryInterface.addIndex('contacts', ['email']); await queryInterface.addIndex('contacts', ['status']); await queryInterface.addIndex('contacts', ['createdAt']); }, down: async (queryInterface, Sequelize) => { await queryInterface.dropTable('contacts'); } };