98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const Context = sequelize.define('Context', {
|
|
uuid: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
comment: 'Unique identifier for context'
|
|
},
|
|
title: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: false,
|
|
comment: 'Title of the context item'
|
|
},
|
|
context: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'Context description'
|
|
},
|
|
grade : {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 100,
|
|
comment: 'It is number of gradeX100 + unitX10 + lesson (e.g., Grade 1 Unit 2 Lesson 3 = 123)'
|
|
},
|
|
knowledge: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'Additional knowledge or information'
|
|
},
|
|
type: {
|
|
type: DataTypes.STRING(50),
|
|
allowNull: false,
|
|
comment: 'Context type (e.g., vocabulary, grammar)'
|
|
},
|
|
desc: {
|
|
type: DataTypes.TEXT,
|
|
comment: 'Detailed description or requirement'
|
|
},
|
|
img_prompt: {
|
|
type: DataTypes.JSON,
|
|
comment: 'Prompt configuration object'
|
|
},
|
|
image: {
|
|
type: DataTypes.TEXT,
|
|
comment: 'Single image URL string'
|
|
},
|
|
type_context: {
|
|
type: DataTypes.STRING(50),
|
|
comment: 'Type of context (e.g., example_sentence, dialogue)'
|
|
},
|
|
type_image: {
|
|
type: DataTypes.STRING(50),
|
|
comment: 'Type of image (e.g., small, square, normal)'
|
|
},
|
|
max: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 1,
|
|
comment: 'Maximum number of images or items'
|
|
},
|
|
status: {
|
|
type: DataTypes.INTEGER, // Hoặc DataTypes.ENUM('DRAFT', 'ENRICHED', 'PENDING_IMAGE', ...)
|
|
defaultValue: 0,
|
|
comment: '0: Draft, 1: Enriched, 2: Prompt_Ready, 3: Generating, 4: Image_Ready, 5: Approved'
|
|
},
|
|
reference_id: {
|
|
type: DataTypes.UUID,
|
|
comment: 'Reference to another entity if applicable'
|
|
},
|
|
created_at: {
|
|
type: DataTypes.DATE,
|
|
defaultValue: DataTypes.NOW
|
|
},
|
|
updated_at: {
|
|
type: DataTypes.DATE,
|
|
defaultValue: DataTypes.NOW
|
|
}
|
|
}, {
|
|
tableName: 'context',
|
|
timestamps: true,
|
|
underscored: false,
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at',
|
|
indexes: [
|
|
{
|
|
name: 'idx_context_type',
|
|
fields: ['type']
|
|
},
|
|
{
|
|
name: 'idx_context_title',
|
|
fields: ['title']
|
|
}
|
|
]
|
|
});
|
|
|
|
module.exports = Context;
|