Overview
I've successfully implemented optional video scripts with company-level settings and support for both long-form (YouTube) and short-form (YouTube Shorts, TikTok) content.
Changes Made
1. Schema Updates (backend/prisma/schema.prisma)
Company Model
- Added:
showScriptsBoolean field (default:true)- Allows companies to enable/disable the script feature at the organization level
- When disabled, videos can still be created, but scripts are optional
- Added: Relation to
VideoScriptmodel
User Model
- Added: Relation to
VideoScriptmodel for tracking user-created scripts
New VideoScript Model
- Multi-tenant fields:
companyId,userId(with proper relations) - Video Details:
title,description - Platform & Type:
platform: "youtube", "youtube_shorts", "tiktok", "instagram_reels"scriptType: "long_form" or "short_form"
- Optional Script Content:
longFormScript(JSON, nullable): Structured script for YouTube videosjson{ "hook": "...", "intro": "...", "mainContent": [ { "section": "...", "content": "...", "duration": "..." } ], "cta": "..." }shortFormScript(JSON, nullable): Structured script for short-form contentjson{ "hook": "...", "body": "...", "cta": "..." }
- Video Metadata:
estimatedDurationtags(array)thumbnailPrompt
- AI Tracking:
aiProvider,modelName,promptUsed - Linked Content:
linkedBlogId,campaignId - Status: "draft", "ready", "recorded", "published"
- Proper indexes for performance optimization
2. Seed File Updates (backend/prisma/seed.ts)
Sample Data Created:
Company 1 (TechFlow MSP) - Scripts enabled
- Long-form YouTube video: "5 Critical Cybersecurity Mistakes Small Businesses Make"
- Complete with structured script including hook, intro, 5 content sections, and CTA
Company 2 (Wellness Chiropractic) - Scripts enabled
- TikTok short: "Quick Desk Stretch to Relieve Back Pain" (30 seconds)
- YouTube Shorts: "Myth Busting: Chiropractors Aren't Real Doctors" (45 seconds)
Company 3 (Pawsitive Impact) - Scripts disabled (
showScripts: false)- YouTube video: "Meet Luna: A Day in Service Dog Training"
- Demonstrates how videos work when scripts are disabled (script content is null)
All sample videos include:
- Platform-specific content
- Appropriate script types
- Tags and thumbnail prompts
- AI generation metadata
3. Key Features Implemented
✅ Optional Scripts
- Scripts are optional at both the company level (via
showScriptssetting) and individual video level (nullable fields)
✅ Company-Level Control
showScriptsboolean in Company model- When
false, the UI can hide script-related features - Videos can still be created without scripts
✅ Long-Form Support (YouTube)
- Structured with: hook, intro, main content sections (array), CTA
- Each content section can have its own duration
- Total estimated duration tracked
✅ Short-Form Support (YouTube Shorts, TikTok)
- Simpler structure: hook, body, CTA
- Optimized for quick, engaging content
- Platform-specific tags
✅ Granular Permissions Ready
- Individual videos can have scripts (not null) or no scripts (null)
- User-level permissions will be handled separately per your requirements
Next Steps
1. Run Database Migration
⚠️ Important: You need to run the migration when DATABASE_URL is available.
bash
cd backend
# Option 1: If you have DATABASE_URL in environment
pnpm prisma migrate dev --name add_video_scripts_and_company_settings
# Option 2: Generate migration file for later deployment
pnpm prisma migrate dev --create-only --name add_video_scripts_and_company_settings2. Verify Migration
bash
# Open Prisma Studio to see the new models
pnpm prisma studio3. Seed Demo Data
bash
# Set NODE_ENV to development and run seed
NODE_ENV=development pnpm run seed4. Frontend Integration
You'll need to:
- Update VideoIdea type to match the new schema
- Add company settings UI for
showScriptstoggle - Create/update VideoStudio component to:
- Check company's
showScriptssetting - Show/hide script editor based on setting
- Support both long-form and short-form script editing
- Allow creating videos without scripts
- Check company's
- Add script type selector (long_form vs short_form)
- Add platform selector (youtube, youtube_shorts, tiktok, instagram_reels)
5. Backend API Endpoints (Recommended)
Create these endpoints:
POST /api/videos- Create video with optional scriptGET /api/videos- List videos (filtered by companyId)GET /api/videos/:id- Get video detailsPUT /api/videos/:id- Update video and scriptDELETE /api/videos/:id- Delete videoPOST /api/videos/:id/generate-script- AI-generate scriptGET /api/company/settings- Get company settings (including showScripts)PATCH /api/company/settings- Update company settings
Database Schema Summary
Company
├── showScripts: Boolean (default: true)
└── videoScripts: VideoScript[]
User
└── videoScripts: VideoScript[]
VideoScript
├── id: UUID
├── companyId: String (required)
├── userId: String (required)
├── title: String (required)
├── description: String? (optional)
├── platform: String (youtube|youtube_shorts|tiktok|instagram_reels)
├── scriptType: String (long_form|short_form)
├── longFormScript: JSON? (optional, for YouTube)
├── shortFormScript: JSON? (optional, for short-form content)
├── estimatedDuration: String?
├── tags: String[]
├── thumbnailPrompt: String?
├── aiProvider: String?
├── modelName: String?
├── promptUsed: String?
├── linkedBlogId: String?
├── campaignId: String?
├── status: String (draft|ready|recorded|published)
├── publishedAt: DateTime?
├── createdAt: DateTime
└── updatedAt: DateTimeSample Script Structures
Long-Form (YouTube)
json
{
"hook": "Opening hook to grab attention",
"intro": "Introduction to the topic",
"mainContent": [
{
"section": "Section Title",
"content": "Section content with details",
"duration": "2:30"
}
],
"cta": "Call to action - subscribe, link, etc."
}Short-Form (TikTok, YouTube Shorts)
json
{
"hook": "Quick attention grabber",
"body": "Main content in concise format",
"cta": "Short CTA with hashtags"
}Benefits
- Flexibility: Companies can choose whether to use scripts
- Platform-Specific: Different script structures for different platforms
- Optional: Videos can exist without scripts
- Multi-Tenant: Proper data isolation with companyId
- Scalable: Supports future platforms and script types
- AI-Ready: Fields for AI generation metadata
- Campaign Integration: Can link to campaigns and blog posts. AI scripts now ingest Campaign Brief/Goal for context-aware generation.
Status: ✅ Schema updated, seed file ready Remaining: Database migration needs to be run when DATABASE_URL is available