diff --git a/alembic/env.py b/alembic/env.py index 41c3965..cad861c 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -24,8 +24,8 @@ target_metadata = Base.metadata -# Update URL from settings -config.set_main_option("sqlalchemy.url", settings.DATABASE_URL) +# Update URL from settings (use async URL for async migrations) +config.set_main_option("sqlalchemy.url", settings.database_url_async) def run_migrations_offline() -> None: diff --git a/alembic/versions/002_add_api_key_table.py b/alembic/versions/002_add_api_key_table.py index 0d1d5bc..a2c6845 100644 --- a/alembic/versions/002_add_api_key_table.py +++ b/alembic/versions/002_add_api_key_table.py @@ -11,7 +11,7 @@ # revision identifiers, used by Alembic. revision = '002_add_api_key_table' -down_revision = '001_initial_schema' +down_revision = '001' branch_labels = None depends_on = None diff --git a/alembic/versions/003_add_performance_indexes.py b/alembic/versions/003_add_performance_indexes.py index eadb308..b5b8d42 100644 --- a/alembic/versions/003_add_performance_indexes.py +++ b/alembic/versions/003_add_performance_indexes.py @@ -16,28 +16,16 @@ def upgrade(): """Add performance indexes for frequently queried columns.""" - # Jobs table indexes - op.create_index(op.f('ix_jobs_api_key'), 'jobs', ['api_key']) - op.create_index(op.f('ix_jobs_status'), 'jobs', ['status']) + # Jobs table indexes (ix_jobs_api_key and ix_jobs_status already exist from 001) op.create_index(op.f('ix_jobs_created_at'), 'jobs', ['created_at']) op.create_index(op.f('ix_jobs_status_api_key'), 'jobs', ['status', 'api_key']) op.create_index(op.f('ix_jobs_api_key_created_at'), 'jobs', ['api_key', 'created_at']) - - # API keys table indexes - op.create_index(op.f('ix_api_keys_key_hash'), 'api_keys', ['key_hash']) - op.create_index(op.f('ix_api_keys_is_active'), 'api_keys', ['is_active']) - op.create_index(op.f('ix_api_keys_expires_at'), 'api_keys', ['expires_at']) + # API keys indexes already created in migration 002 def downgrade(): """Remove performance indexes.""" - # Jobs table indexes + # Jobs table indexes (only drop ones added by this migration) op.drop_index(op.f('ix_jobs_api_key_created_at'), table_name='jobs') op.drop_index(op.f('ix_jobs_status_api_key'), table_name='jobs') op.drop_index(op.f('ix_jobs_created_at'), table_name='jobs') - op.drop_index(op.f('ix_jobs_status'), table_name='jobs') - op.drop_index(op.f('ix_jobs_api_key'), table_name='jobs') - - # API keys table indexes - op.drop_index(op.f('ix_api_keys_expires_at'), table_name='api_keys') - op.drop_index(op.f('ix_api_keys_is_active'), table_name='api_keys') - op.drop_index(op.f('ix_api_keys_key_hash'), table_name='api_keys') \ No newline at end of file + # API keys indexes managed by migration 002 \ No newline at end of file diff --git a/alembic/versions/004_add_job_progress_columns.py b/alembic/versions/004_add_job_progress_columns.py index b12231b..3b7c022 100644 --- a/alembic/versions/004_add_job_progress_columns.py +++ b/alembic/versions/004_add_job_progress_columns.py @@ -13,7 +13,7 @@ # revision identifiers, used by Alembic. revision: str = '004' -down_revision: Union[str, None] = '003' +down_revision: Union[str, None] = '003_add_performance_indexes' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None diff --git a/api/config.py b/api/config.py index afc76be..5b2435c 100644 --- a/api/config.py +++ b/api/config.py @@ -19,6 +19,7 @@ class Settings(BaseSettings): env_file=".env", env_file_encoding="utf-8", case_sensitive=False, + extra="ignore", # Ignore extra fields in .env file ) # Application diff --git a/api/models/job.py b/api/models/job.py index 3e537a7..2e5a961 100644 --- a/api/models/job.py +++ b/api/models/job.py @@ -9,7 +9,7 @@ """ from datetime import datetime from enum import Enum -from typing import Optional, Dict, Any, List, Annotated +from typing import Optional, Dict, Any, List, Annotated, Union from uuid import UUID, uuid4 from sqlalchemy import Column, String, JSON, DateTime, Float, Integer, Index @@ -154,7 +154,7 @@ class ConvertRequest(BaseModel): ) input: Annotated[ - str | Dict[str, Any], + Union[str, Dict[str, Any]], Field( description="Input file path or configuration object", examples=["/storage/input/video.mp4", {"path": "/storage/video.mp4", "backend": "s3"}] @@ -163,7 +163,7 @@ class ConvertRequest(BaseModel): ] output: Annotated[ - str | Dict[str, Any], + Union[str, Dict[str, Any]], Field( description="Output file path or configuration object", examples=["/storage/output/video.webm"]