Skip to content

Commit 46d1524

Browse files
authored
Merge pull request #36 from rendiffdev/migration-fixes
Fix migration chain and Python 3.9 compatibility
2 parents b9409e3 + 14a5928 commit 46d1524

File tree

6 files changed

+12
-23
lines changed

6 files changed

+12
-23
lines changed

alembic/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
target_metadata = Base.metadata
2626

27-
# Update URL from settings
28-
config.set_main_option("sqlalchemy.url", settings.DATABASE_URL)
27+
# Update URL from settings (use async URL for async migrations)
28+
config.set_main_option("sqlalchemy.url", settings.database_url_async)
2929

3030

3131
def run_migrations_offline() -> None:

alembic/versions/002_add_api_key_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# revision identifiers, used by Alembic.
1313
revision = '002_add_api_key_table'
14-
down_revision = '001_initial_schema'
14+
down_revision = '001'
1515
branch_labels = None
1616
depends_on = None
1717

alembic/versions/003_add_performance_indexes.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,16 @@
1616

1717
def upgrade():
1818
"""Add performance indexes for frequently queried columns."""
19-
# Jobs table indexes
20-
op.create_index(op.f('ix_jobs_api_key'), 'jobs', ['api_key'])
21-
op.create_index(op.f('ix_jobs_status'), 'jobs', ['status'])
19+
# Jobs table indexes (ix_jobs_api_key and ix_jobs_status already exist from 001)
2220
op.create_index(op.f('ix_jobs_created_at'), 'jobs', ['created_at'])
2321
op.create_index(op.f('ix_jobs_status_api_key'), 'jobs', ['status', 'api_key'])
2422
op.create_index(op.f('ix_jobs_api_key_created_at'), 'jobs', ['api_key', 'created_at'])
25-
26-
# API keys table indexes
27-
op.create_index(op.f('ix_api_keys_key_hash'), 'api_keys', ['key_hash'])
28-
op.create_index(op.f('ix_api_keys_is_active'), 'api_keys', ['is_active'])
29-
op.create_index(op.f('ix_api_keys_expires_at'), 'api_keys', ['expires_at'])
23+
# API keys indexes already created in migration 002
3024

3125
def downgrade():
3226
"""Remove performance indexes."""
33-
# Jobs table indexes
27+
# Jobs table indexes (only drop ones added by this migration)
3428
op.drop_index(op.f('ix_jobs_api_key_created_at'), table_name='jobs')
3529
op.drop_index(op.f('ix_jobs_status_api_key'), table_name='jobs')
3630
op.drop_index(op.f('ix_jobs_created_at'), table_name='jobs')
37-
op.drop_index(op.f('ix_jobs_status'), table_name='jobs')
38-
op.drop_index(op.f('ix_jobs_api_key'), table_name='jobs')
39-
40-
# API keys table indexes
41-
op.drop_index(op.f('ix_api_keys_expires_at'), table_name='api_keys')
42-
op.drop_index(op.f('ix_api_keys_is_active'), table_name='api_keys')
43-
op.drop_index(op.f('ix_api_keys_key_hash'), table_name='api_keys')
31+
# API keys indexes managed by migration 002

alembic/versions/004_add_job_progress_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# revision identifiers, used by Alembic.
1515
revision: str = '004'
16-
down_revision: Union[str, None] = '003'
16+
down_revision: Union[str, None] = '003_add_performance_indexes'
1717
branch_labels: Union[str, Sequence[str], None] = None
1818
depends_on: Union[str, Sequence[str], None] = None
1919

api/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Settings(BaseSettings):
1919
env_file=".env",
2020
env_file_encoding="utf-8",
2121
case_sensitive=False,
22+
extra="ignore", # Ignore extra fields in .env file
2223
)
2324

2425
# Application

api/models/job.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010
from datetime import datetime
1111
from enum import Enum
12-
from typing import Optional, Dict, Any, List, Annotated
12+
from typing import Optional, Dict, Any, List, Annotated, Union
1313
from uuid import UUID, uuid4
1414

1515
from sqlalchemy import Column, String, JSON, DateTime, Float, Integer, Index
@@ -154,7 +154,7 @@ class ConvertRequest(BaseModel):
154154
)
155155

156156
input: Annotated[
157-
str | Dict[str, Any],
157+
Union[str, Dict[str, Any]],
158158
Field(
159159
description="Input file path or configuration object",
160160
examples=["/storage/input/video.mp4", {"path": "/storage/video.mp4", "backend": "s3"}]
@@ -163,7 +163,7 @@ class ConvertRequest(BaseModel):
163163
]
164164

165165
output: Annotated[
166-
str | Dict[str, Any],
166+
Union[str, Dict[str, Any]],
167167
Field(
168168
description="Output file path or configuration object",
169169
examples=["/storage/output/video.webm"]

0 commit comments

Comments
 (0)