const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); /** * Story Model * Table: stories * Stores story data with metadata, vocabulary, context, grades, and tags */ const Story = sequelize.define('stories', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, allowNull: false, comment: 'Unique identifier for the story (UUID)' }, name: { type: DataTypes.STRING(255), allowNull: false, comment: 'Story title/name' }, thumbnail: { type: DataTypes.TEXT, allowNull: true, comment: 'URL to story thumbnail image' }, logo: { type: DataTypes.TEXT, allowNull: true, comment: 'URL to story logo/thumbnail image' }, vocabulary: { type: DataTypes.JSON, allowNull: true, defaultValue: [], comment: 'Array of vocabulary words used in the story' }, context: { type: DataTypes.JSON, allowNull: true, defaultValue: [], comment: 'Array of story context objects with images, text, audio data' }, type: { type: DataTypes.TEXT, allowNull: false, defaultValue: 'story', comment: 'Type of media content' }, grade: { type: DataTypes.JSON, allowNull: true, defaultValue: [], comment: 'Array of grade levels (e.g., ["Grade 1", "Grade 2"])' }, grade_number: { type: DataTypes.INTEGER, allowNull: true, defaultValue: 0, comment: 'Numeric representation of grade unit lesson as GG UU LL' }, tag: { type: DataTypes.JSON, allowNull: true, defaultValue: [], comment: 'Array of tags for categorization (e.g., ["adventure", "friendship"])' }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, comment: 'Record creation timestamp' }, updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, comment: 'Record last update timestamp' } }, { tableName: 'stories', timestamps: true, underscored: true, indexes: [ { name: 'idx_name', fields: ['name'] }, { name: 'idx_created_at', fields: ['created_at'] } ], charset: 'utf8mb4', collate: 'utf8mb4_unicode_ci' }); module.exports = Story;