chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。 已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
This commit is contained in:
61
database/migrations/002-create-admins.js
Normal file
61
database/migrations/002-create-admins.js
Normal file
@@ -0,0 +1,61 @@
|
||||
'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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user