73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const VocabMapping = sequelize.define('VocabMapping', {
|
|
mapping_id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
comment: 'Unique identifier for curriculum mapping'
|
|
},
|
|
vocab_id: {
|
|
type: DataTypes.UUID,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'vocab',
|
|
key: 'vocab_id'
|
|
},
|
|
onDelete: 'CASCADE',
|
|
comment: 'Reference to vocabulary entry'
|
|
},
|
|
book_id: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
comment: 'Book/curriculum identifier (e.g., global-success-1)'
|
|
},
|
|
grade: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
comment: 'Grade level'
|
|
},
|
|
unit: {
|
|
type: DataTypes.INTEGER,
|
|
comment: 'Unit number in the book'
|
|
},
|
|
lesson: {
|
|
type: DataTypes.INTEGER,
|
|
comment: 'Lesson number in the unit'
|
|
},
|
|
form_key: {
|
|
type: DataTypes.STRING(50),
|
|
comment: 'Which form to use (v1, v_s_es, v_ing, v2, v3, etc.)'
|
|
},
|
|
context_note: {
|
|
type: DataTypes.TEXT,
|
|
comment: 'Additional context for this mapping'
|
|
},
|
|
created_at: {
|
|
type: DataTypes.DATE,
|
|
defaultValue: DataTypes.NOW
|
|
}
|
|
}, {
|
|
tableName: 'vocab_mapping',
|
|
timestamps: true,
|
|
createdAt: 'created_at',
|
|
updatedAt: false,
|
|
indexes: [
|
|
{
|
|
name: 'idx_vocab_mapping_vocab',
|
|
fields: ['vocab_id']
|
|
},
|
|
{
|
|
name: 'idx_vocab_mapping_book_grade',
|
|
fields: ['book_id', 'grade']
|
|
},
|
|
{
|
|
name: 'idx_vocab_mapping_unit_lesson',
|
|
fields: ['unit', 'lesson']
|
|
}
|
|
]
|
|
});
|
|
|
|
module.exports = VocabMapping;
|