const db = require('../models'); const Users = db.users; const Projects = db.projects; const Voices = db.voices; const Scripts = db.scripts; const Scenes = db.scenes; const Assets = db.assets; const Videos = db.videos; const Characters = db.characters; const Templates = db.templates; const ProjectsData = [ { "title": "Educational Series History", "description": "Short documentary style lessons about regional history", "status": "completed", // type code here for "relation_one" field // type code here for "images" field }, { "title": "Marketing Campaign Q2", "description": "Social and paid ads campaign for product launch", "status": "completed", // type code here for "relation_one" field // type code here for "images" field }, { "title": "Teacher Training Clips", "description": "Bite sized training videos for educators", "status": "completed", // type code here for "relation_one" field // type code here for "images" field }, ]; const VoicesData = [ { "name": "Arabic Male Standard", "gender": "female", "language": "Arabic", "speed": 1.0, "pitch": 1.0, "tts_engine": "standard", "is_default": true, }, { "name": "Arabic Female Warm", "gender": "female", "language": "Arabic", "speed": 0.98, "pitch": 0.98, "tts_engine": "custom", "is_default": true, }, { "name": "Arabic Neutral", "gender": "male", "language": "Arabic", "speed": 1.05, "pitch": 1.02, "tts_engine": "neural", "is_default": false, }, ]; const ScriptsData = [ { "title": "History Intro Script", "content": "In this episode we explore ancient trade routes and their cultural impact", "language": "Arabic", // type code here for "relation_one" field // type code here for "relation_one" field "word_count": 18, }, { "title": "Product Launch Hook", "content": "Discover how our solution transforms daily workflows for teams", "language": "Arabic", // type code here for "relation_one" field // type code here for "relation_one" field "word_count": 12, }, { "title": "Teaching Tip 01", "content": "Three practical classroom strategies to boost student engagement", "language": "Arabic", // type code here for "relation_one" field // type code here for "relation_one" field "word_count": 10, }, ]; const ScenesData = [ { "title": "Opening Montage", "order": 1, "duration": 7.5, // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field "notes": "Focus on slow cinematic pans", }, { "title": "Product Feature", "order": 1, "duration": 12.0, // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field "notes": "Highlight interface animations", }, { "title": "Classroom Example", "order": 2, "duration": 9.0, // type code here for "relation_one" field // type code here for "relation_many" field // type code here for "relation_one" field "notes": "Include teacher reaction closeups", }, ]; const AssetsData = [ { "name": "Historic Map Image", "type": "other", // type code here for "files" field // type code here for "images" field // type code here for "relation_one" field "license": "royalty_free", }, { "name": "Cinematic Music Track", "type": "model", // type code here for "files" field // type code here for "images" field // type code here for "relation_one" field "license": "licensed", }, { "name": "Product Interface Video", "type": "video", // type code here for "files" field // type code here for "images" field // type code here for "relation_one" field "license": "owned", }, ]; const VideosData = [ { "title": "History Episode 01", // type code here for "relation_one" field "status": "rendering", "resolution": "1080p", // type code here for "files" field "export_started": new Date('2025-08-01T09:00:00Z'), "export_finished": new Date('2025-08-01T09:12:00Z'), "duration": 300.0, }, { "title": "Q2 Launch Teaser", // type code here for "relation_one" field "status": "completed", "resolution": "4k", // type code here for "files" field "export_started": new Date('2025-09-10T10:00:00Z'), "export_finished": new Date('2025-09-10T10:02:00Z'), "duration": 45.0, }, { "title": "Teacher Training Clip 02", // type code here for "relation_one" field "status": "failed", "resolution": "4k", // type code here for "files" field "export_started": new Date('2025-07-15T14:30:00Z'), "export_finished": new Date('2025-07-15T14:40:00Z'), "duration": 180.0, }, ]; const CharactersData = [ { "name": "Narrator Male", // type code here for "images" field // type code here for "files" field "lip_sync": true, // type code here for "relation_one" field }, { "name": "Teacher Female", // type code here for "images" field // type code here for "files" field "lip_sync": true, // type code here for "relation_one" field }, { "name": "Presenter Neutral", // type code here for "images" field // type code here for "files" field "lip_sync": true, // type code here for "relation_one" field }, ]; const TemplatesData = [ { "name": "Social Promo Pack", "description": "Preset scenes and transitions designed for short promos", // type code here for "images" field // type code here for "relation_one" field // type code here for "relation_many" field }, { "name": "Educational Lesson Pack", "description": "Structured scenes for lesson style videos with lower thirds", // type code here for "images" field // type code here for "relation_one" field // type code here for "relation_many" field }, { "name": "Corporate Teaser Pack", "description": "Sleek templates for corporate announcements and teasers", // type code here for "images" field // type code here for "relation_one" field // type code here for "relation_many" field }, ]; // Similar logic for "relation_many" async function associateProjectWithOwner() { const relatedOwner0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Project0 = await Projects.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Project0?.setOwner) { await Project0. setOwner(relatedOwner0); } const relatedOwner1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Project1 = await Projects.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Project1?.setOwner) { await Project1. setOwner(relatedOwner1); } const relatedOwner2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Project2 = await Projects.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Project2?.setOwner) { await Project2. setOwner(relatedOwner2); } } async function associateScriptWithVoice() { const relatedVoice0 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Script0 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Script0?.setVoice) { await Script0. setVoice(relatedVoice0); } const relatedVoice1 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Script1 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Script1?.setVoice) { await Script1. setVoice(relatedVoice1); } const relatedVoice2 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Script2 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Script2?.setVoice) { await Script2. setVoice(relatedVoice2); } } async function associateScriptWithProject() { const relatedProject0 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Script0 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Script0?.setProject) { await Script0. setProject(relatedProject0); } const relatedProject1 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Script1 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Script1?.setProject) { await Script1. setProject(relatedProject1); } const relatedProject2 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Script2 = await Scripts.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Script2?.setProject) { await Script2. setProject(relatedProject2); } } async function associateSceneWithScript() { const relatedScript0 = await Scripts.findOne({ offset: Math.floor(Math.random() * (await Scripts.count())), }); const Scene0 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Scene0?.setScript) { await Scene0. setScript(relatedScript0); } const relatedScript1 = await Scripts.findOne({ offset: Math.floor(Math.random() * (await Scripts.count())), }); const Scene1 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Scene1?.setScript) { await Scene1. setScript(relatedScript1); } const relatedScript2 = await Scripts.findOne({ offset: Math.floor(Math.random() * (await Scripts.count())), }); const Scene2 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Scene2?.setScript) { await Scene2. setScript(relatedScript2); } } // Similar logic for "relation_many" async function associateSceneWithCharacter() { const relatedCharacter0 = await Characters.findOne({ offset: Math.floor(Math.random() * (await Characters.count())), }); const Scene0 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Scene0?.setCharacter) { await Scene0. setCharacter(relatedCharacter0); } const relatedCharacter1 = await Characters.findOne({ offset: Math.floor(Math.random() * (await Characters.count())), }); const Scene1 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Scene1?.setCharacter) { await Scene1. setCharacter(relatedCharacter1); } const relatedCharacter2 = await Characters.findOne({ offset: Math.floor(Math.random() * (await Characters.count())), }); const Scene2 = await Scenes.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Scene2?.setCharacter) { await Scene2. setCharacter(relatedCharacter2); } } async function associateAssetWithUploaded_by() { const relatedUploaded_by0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Asset0 = await Assets.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Asset0?.setUploaded_by) { await Asset0. setUploaded_by(relatedUploaded_by0); } const relatedUploaded_by1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Asset1 = await Assets.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Asset1?.setUploaded_by) { await Asset1. setUploaded_by(relatedUploaded_by1); } const relatedUploaded_by2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Asset2 = await Assets.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Asset2?.setUploaded_by) { await Asset2. setUploaded_by(relatedUploaded_by2); } } async function associateVideoWithProject() { const relatedProject0 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Video0 = await Videos.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Video0?.setProject) { await Video0. setProject(relatedProject0); } const relatedProject1 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Video1 = await Videos.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Video1?.setProject) { await Video1. setProject(relatedProject1); } const relatedProject2 = await Projects.findOne({ offset: Math.floor(Math.random() * (await Projects.count())), }); const Video2 = await Videos.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Video2?.setProject) { await Video2. setProject(relatedProject2); } } async function associateCharacterWithDefault_voice() { const relatedDefault_voice0 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Character0 = await Characters.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Character0?.setDefault_voice) { await Character0. setDefault_voice(relatedDefault_voice0); } const relatedDefault_voice1 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Character1 = await Characters.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Character1?.setDefault_voice) { await Character1. setDefault_voice(relatedDefault_voice1); } const relatedDefault_voice2 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Character2 = await Characters.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Character2?.setDefault_voice) { await Character2. setDefault_voice(relatedDefault_voice2); } } async function associateTemplateWithDefault_voice() { const relatedDefault_voice0 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Template0 = await Templates.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Template0?.setDefault_voice) { await Template0. setDefault_voice(relatedDefault_voice0); } const relatedDefault_voice1 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Template1 = await Templates.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Template1?.setDefault_voice) { await Template1. setDefault_voice(relatedDefault_voice1); } const relatedDefault_voice2 = await Voices.findOne({ offset: Math.floor(Math.random() * (await Voices.count())), }); const Template2 = await Templates.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Template2?.setDefault_voice) { await Template2. setDefault_voice(relatedDefault_voice2); } } // Similar logic for "relation_many" module.exports = { up: async (queryInterface, Sequelize) => { await Projects.bulkCreate(ProjectsData); await Voices.bulkCreate(VoicesData); await Scripts.bulkCreate(ScriptsData); await Scenes.bulkCreate(ScenesData); await Assets.bulkCreate(AssetsData); await Videos.bulkCreate(VideosData); await Characters.bulkCreate(CharactersData); await Templates.bulkCreate(TemplatesData); await Promise.all([ // Similar logic for "relation_many" await associateProjectWithOwner(), await associateScriptWithVoice(), await associateScriptWithProject(), await associateSceneWithScript(), // Similar logic for "relation_many" await associateSceneWithCharacter(), await associateAssetWithUploaded_by(), await associateVideoWithProject(), await associateCharacterWithDefault_voice(), await associateTemplateWithDefault_voice(), // Similar logic for "relation_many" ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('projects', null, {}); await queryInterface.bulkDelete('voices', null, {}); await queryInterface.bulkDelete('scripts', null, {}); await queryInterface.bulkDelete('scenes', null, {}); await queryInterface.bulkDelete('assets', null, {}); await queryInterface.bulkDelete('videos', null, {}); await queryInterface.bulkDelete('characters', null, {}); await queryInterface.bulkDelete('templates', null, {}); }, };