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:
WorkBuddy
2026-08-17 12:25:42 +08:00
commit a303cf2d53
109 changed files with 25904 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('accounts', {
uid: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '用户唯一标识',
},
role: {
type: Sequelize.STRING(32),
allowNull: false,
defaultValue: 'student',
comment: '角色:student/teacher/judge/admin',
},
name_cn: {
type: Sequelize.STRING(64),
allowNull: false,
comment: '中文姓名',
},
name_en: {
type: Sequelize.STRING(128),
allowNull: true,
comment: '英文姓名/拼音',
},
gender: {
type: Sequelize.STRING(8),
allowNull: true,
comment: '性别:男/女',
},
phone: {
type: Sequelize.STRING(32),
allowNull: true,
comment: '手机号码',
},
email: {
type: Sequelize.STRING(128),
allowNull: true,
comment: '电子邮箱',
},
id_number: {
type: Sequelize.STRING(32),
allowNull: false,
unique: true,
comment: '身份证号(唯一)',
},
password: {
type: Sequelize.STRING(128),
allowNull: false,
comment: '密码(加密存储)',
},
salt: {
type: Sequelize.STRING(64),
allowNull: false,
comment: '密码盐值',
},
position: {
type: Sequelize.STRING(64),
allowNull: true,
comment: '职务/职称',
},
major: {
type: Sequelize.STRING(128),
allowNull: true,
comment: '专业',
},
country: {
type: Sequelize.STRING(64),
allowNull: true,
comment: '国家',
},
region: {
type: Sequelize.STRING(64),
allowNull: true,
comment: '地区/省份',
},
organization_cn: {
type: Sequelize.STRING(255),
allowNull: true,
comment: '所属单位(中文)',
},
organization_en: {
type: Sequelize.STRING(255),
allowNull: true,
comment: '所属单位(英文)',
},
activated: {
type: Sequelize.TINYINT,
allowNull: false,
defaultValue: 0,
comment: '激活状态:0未激活 1已激活',
},
score: {
type: Sequelize.INTEGER,
allowNull: true,
comment: '总分/积分',
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
comment: '更新时间',
},
}).then(() => {
return Promise.all([
queryInterface.addIndex('accounts', ['role'], { name: 'idx_role' }),
queryInterface.addIndex('accounts', ['phone'], { name: 'idx_phone' }),
queryInterface.addIndex('accounts', ['name_cn'], { name: 'idx_name_cn' }),
]);
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('accounts');
},
};