72 lines
1.6 KiB
JavaScript
72 lines
1.6 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const GrammarMediaStory = sequelize.define('GrammarMediaStory', {
|
|
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'
|
|
},
|
|
story_id: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
comment: 'Unique story identifier (e.g., "st-01")'
|
|
},
|
|
title: {
|
|
type: DataTypes.STRING(200),
|
|
allowNull: false,
|
|
comment: 'Story title'
|
|
},
|
|
type: {
|
|
type: DataTypes.ENUM('story', 'video', 'animation', 'audio'),
|
|
allowNull: false,
|
|
defaultValue: 'story',
|
|
comment: 'Media type'
|
|
},
|
|
url: {
|
|
type: DataTypes.STRING(500),
|
|
allowNull: false,
|
|
comment: 'Single URL to the complete media file'
|
|
},
|
|
thumbnail: {
|
|
type: DataTypes.STRING(500),
|
|
allowNull: true,
|
|
comment: 'Thumbnail image URL'
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'Story description'
|
|
},
|
|
duration_seconds: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
comment: 'Media duration in seconds'
|
|
},
|
|
min_grade: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
comment: 'Minimum grade level for this story'
|
|
}
|
|
}, {
|
|
tableName: 'grammar_media_stories',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['grammar_id'] },
|
|
{ fields: ['story_id'] },
|
|
{ fields: ['type'] }
|
|
]
|
|
});
|
|
|
|
module.exports = GrammarMediaStory;
|