File size: 2,093 Bytes
6aecb2e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | """
Add speech_scripts table migration
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../..'))
from sqlalchemy import text
from landppt.database.database import engine
def upgrade():
"""Create speech_scripts table"""
with engine.connect() as conn:
# Create speech_scripts table
conn.execute(text("""
CREATE TABLE IF NOT EXISTS speech_scripts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
project_id VARCHAR(36) NOT NULL,
slide_index INTEGER NOT NULL,
slide_title VARCHAR(255) NOT NULL,
script_content TEXT NOT NULL,
estimated_duration VARCHAR(50),
speaker_notes TEXT,
generation_type VARCHAR(20) NOT NULL,
tone VARCHAR(50) NOT NULL,
target_audience VARCHAR(100) NOT NULL,
custom_audience TEXT,
language_complexity VARCHAR(20) NOT NULL,
speaking_pace VARCHAR(20) NOT NULL,
custom_style_prompt TEXT,
include_transitions BOOLEAN NOT NULL DEFAULT 1,
include_timing_notes BOOLEAN NOT NULL DEFAULT 0,
created_at REAL NOT NULL,
updated_at REAL NOT NULL,
FOREIGN KEY (project_id) REFERENCES projects (project_id)
)
"""))
# Create indexes
conn.execute(text("""
CREATE INDEX IF NOT EXISTS idx_speech_scripts_project_id
ON speech_scripts (project_id)
"""))
conn.execute(text("""
CREATE INDEX IF NOT EXISTS idx_speech_scripts_project_slide
ON speech_scripts (project_id, slide_index)
"""))
conn.commit()
def downgrade():
"""Drop speech_scripts table"""
with engine.connect() as conn:
conn.execute(text("DROP TABLE IF EXISTS speech_scripts"))
conn.commit()
if __name__ == "__main__":
upgrade()
print("Speech scripts table created successfully!")
|