This commit is contained in:
silverpro89
2026-01-26 20:23:08 +07:00
parent 53d97ba5db
commit 2c7b4675a7
49 changed files with 12668 additions and 1 deletions

56
models/GrammarMapping.js Normal file
View File

@@ -0,0 +1,56 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const GrammarMapping = sequelize.define('GrammarMapping', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
grammar_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'grammars',
key: 'id'
},
onDelete: 'CASCADE',
comment: 'Foreign key to grammars table'
},
book_id: {
type: DataTypes.STRING(100),
allowNull: false,
comment: 'Book identifier (e.g., "global-success-2")'
},
grade: {
type: DataTypes.INTEGER,
allowNull: false,
comment: 'Grade level'
},
unit: {
type: DataTypes.INTEGER,
allowNull: true,
comment: 'Unit number in the book'
},
lesson: {
type: DataTypes.INTEGER,
allowNull: true,
comment: 'Lesson number within the unit'
},
context_note: {
type: DataTypes.TEXT,
allowNull: true,
comment: 'Additional context about where this grammar appears'
}
}, {
tableName: 'grammar_mappings',
timestamps: true,
indexes: [
{ fields: ['grammar_id'] },
{ fields: ['book_id'] },
{ fields: ['grade'] },
{ fields: ['book_id', 'grade', 'unit', 'lesson'] }
]
});
module.exports = GrammarMapping;