'use strict'; /** * 迁移文件:创建管理员表(admins) * 存储后台管理员账号信息 */ module.exports = { /** * 执行迁移:创建 admins 表 * @param {import('sequelize').QueryInterface} queryInterface * @param {import('sequelize').Sequelize} Sequelize */ up: async (queryInterface, Sequelize) => { const { INTEGER, STRING, DATE } = Sequelize; await queryInterface.createTable('admins', { id: { type: INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, comment: '管理员唯一标识', }, username: { type: STRING(50), allowNull: false, unique: true, comment: '管理员用户名', }, password: { type: STRING(100), allowNull: false, comment: '管理员密码', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, }); await queryInterface.addIndex('admins', ['username'], { unique: true, name: 'idx_admins_username', }); }, /** * 回滚迁移:删除 admins 表 * @param {import('sequelize').QueryInterface} queryInterface */ down: async (queryInterface) => { await queryInterface.dropTable('admins'); }, };