Files
competition-website/app/model/systemConfig.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
/**
* 系统配置模型 - SystemConfig
*
* 存储系统级别的配置项,以键值对形式存储。
* 表名:system_configs
*/
module.exports = app => {
const { STRING, TEXT, INTEGER, DATE } = app.Sequelize;
const SystemConfig = app.model.define('system_config', {
// 主键 ID,自增
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '配置唯一标识',
},
// 配置键名,唯一
config_key: {
type: STRING(100),
allowNull: false,
unique: true,
comment: '配置键名',
},
// 配置值(文本存储,可存储 JSON 字符串)
config_value: {
type: TEXT,
allowNull: false,
comment: '配置值',
},
// 记录创建时间
created_at: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
// 记录更新时间
updated_at: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '更新时间',
},
}, {
tableName: 'system_configs',
timestamps: false,
underscored: true,
});
return SystemConfig;
};