61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
"""Add YouTube audio support
|
|
|
|
Revision ID: fc2ec8c4e929
|
|
Revises: 1252454a2589
|
|
Create Date: 2025-12-20 21:07:01.804139
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'fc2ec8c4e929'
|
|
down_revision = '1252454a2589'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('download_jobs',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('question_id', sa.Integer(), nullable=False),
|
|
sa.Column('celery_task_id', sa.String(length=255), nullable=False),
|
|
sa.Column('status', sa.Enum('PENDING', 'PROCESSING', 'COMPLETED', 'FAILED', name='downloadjobstatus'), nullable=False),
|
|
sa.Column('progress', sa.Integer(), nullable=True),
|
|
sa.Column('error_message', sa.Text(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('completed_at', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('celery_task_id')
|
|
)
|
|
with op.batch_alter_table('questions', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('youtube_url', sa.String(length=500), nullable=True))
|
|
batch_op.add_column(sa.Column('audio_path', sa.String(length=255), nullable=True))
|
|
batch_op.add_column(sa.Column('start_time', sa.Integer(), nullable=True))
|
|
batch_op.add_column(sa.Column('end_time', sa.Integer(), nullable=True))
|
|
batch_op.alter_column('type',
|
|
existing_type=sa.VARCHAR(length=5),
|
|
type_=sa.Enum('TEXT', 'IMAGE', 'YOUTUBE_AUDIO', name='questiontype'),
|
|
existing_nullable=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('questions', schema=None) as batch_op:
|
|
batch_op.alter_column('type',
|
|
existing_type=sa.Enum('TEXT', 'IMAGE', 'YOUTUBE_AUDIO', name='questiontype'),
|
|
type_=sa.VARCHAR(length=5),
|
|
existing_nullable=False)
|
|
batch_op.drop_column('end_time')
|
|
batch_op.drop_column('start_time')
|
|
batch_op.drop_column('audio_path')
|
|
batch_op.drop_column('youtube_url')
|
|
|
|
op.drop_table('download_jobs')
|
|
# ### end Alembic commands ###
|