Files
yunke/yunke-server/migrations/versions/c4d5e6f7a8b9_voice_clip_media_hash.py
T

35 lines
1.1 KiB
Python
Raw Normal View History

"""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')