538a0dc635
Mirror download_call_recordings pattern for voice_clips:
- VoiceClip.media_hash column + Alembic migration (c4d5e6f7a8b9)
- VoiceClipOut.media_hash + frontend VoiceClip.media_hash type
- download_voice_clip_audio in app/scraper/media.py (resilient, sha256-dedup,
same download_url/upsert_media helpers as call recordings)
- sync_voice_clip_audio orchestrator wrapper (commits own SyncRun, mirrors
sync_call_recordings semantics)
- scheduler: _run_voice_clip_audio + ENTITY_FUNCS['voice_clip_audio'] +
appended to daily _run_all job (after voice_clips)
- VoiceClipModal playClip local-first: /api/media/{media_hash} with OSS
oss_file_name fallback (mirrors CallList.playRecord)
Tested: 376 pytest pass; vue-tsc clean; migration applied; 1523/1533 clips
localized (10 pending are genuine upstream HTTP 404s — resilient skip).
Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""voice_clip media_hash
|
|
|
|
Revision ID: c4d5e6f7a8b9
|
|
Revises: b3c4d5e6f7a8
|
|
Create Date: 2026-08-11 00:00:00.000000
|
|
|
|
"""
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'c4d5e6f7a8b9'
|
|
down_revision: str | Sequence[str] | None = 'b3c4d5e6f7a8'
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# sha256 media_hash of the localized audio blob (FK -> Media.media_hash).
|
|
# NULL until sync_voice_clip_audio downloads it. batch_alter_table keeps
|
|
# this portable across SQLite (dev/test, table-recreate) and MySQL (prod,
|
|
# direct ALTER). Mirrors the phone_call.record_media_hash migration.
|
|
with op.batch_alter_table('voice_clip', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('media_hash', sa.String(length=64), nullable=True))
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
with op.batch_alter_table('voice_clip', schema=None) as batch_op:
|
|
batch_op.drop_column('media_hash')
|