update
This commit is contained in:
29
models/Subject.js
Normal file
29
models/Subject.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const Subject = sequelize.define('subjects', {
|
||||
id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
|
||||
subject_code: { type: DataTypes.STRING(20), unique: true, allowNull: false },
|
||||
subject_name: { type: DataTypes.STRING(100), allowNull: false },
|
||||
subject_name_en: { type: DataTypes.STRING(100) },
|
||||
description: { type: DataTypes.TEXT },
|
||||
is_active: { type: DataTypes.BOOLEAN, defaultValue: true },
|
||||
is_premium: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung premium' },
|
||||
is_training: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung đào tạo nhân sự' },
|
||||
is_public: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung tự học công khai' },
|
||||
required_role: { type: DataTypes.STRING(50), comment: 'Role yêu cầu' },
|
||||
min_subscription_tier: { type: DataTypes.STRING(50), comment: 'Gói tối thiểu: basic, premium, vip' },
|
||||
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||
}, {
|
||||
tableName: 'subjects',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{ fields: ['is_premium'] },
|
||||
{ fields: ['is_training'] },
|
||||
{ fields: ['is_public'] },
|
||||
],
|
||||
});
|
||||
|
||||
module.exports = Subject;
|
||||
Reference in New Issue
Block a user