BREAKING CHANGE: This commit introduces significant schema changes that require a fresh database. See migration instructions below. Changes: - Added Flask-Login and bcrypt dependencies to pyproject.toml - Created User model with password hashing methods - Updated Channel model: - Added user_id foreign key relationship - Added rss_url field - Renamed last_fetched to last_fetched_at - Added composite unique index on (user_id, channel_id) - Updated VideoEntry model: - Added video_id, video_url, thumbnail_url, description, published_at fields - Renamed link to video_url - Added indexes for performance - Updated feed_parser.py: - Enhanced FeedEntry to extract thumbnail, description, published date - Added _extract_video_id() method for parsing YouTube URLs - Updated save_to_db() to require user_id parameter - Parse and store all metadata from RSS feeds - Generated Alembic migration: a3c56d47f42a Migration Instructions: 1. Stop all services: docker-compose down -v 2. Apply migrations: docker-compose up -d && docker-compose exec app alembic upgrade head 3. Or for local dev: rm yottob.db && alembic upgrade head Next Steps (TODO): - Configure Flask-Login in main.py - Create login/register/logout routes - Add @login_required decorators to protected routes - Update all routes to filter by current_user - Create auth templates (login.html, register.html) - Update base.html with auth navigation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
84 lines
4.4 KiB
Python
84 lines
4.4 KiB
Python
"""Add user authentication and enhance video fields
|
|
|
|
Revision ID: a3c56d47f42a
|
|
Revises: 1b18a0e65b0d
|
|
Create Date: 2025-11-26 14:22:55.689811
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'a3c56d47f42a'
|
|
down_revision: Union[str, Sequence[str], None] = '1b18a0e65b0d'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('users',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(length=80), nullable=False),
|
|
sa.Column('email', sa.String(length=120), nullable=False),
|
|
sa.Column('password_hash', sa.String(length=255), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
|
|
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
|
|
op.add_column('channels', sa.Column('user_id', sa.Integer(), nullable=False))
|
|
op.add_column('channels', sa.Column('rss_url', sa.String(length=500), nullable=False))
|
|
op.add_column('channels', sa.Column('last_fetched_at', sa.DateTime(), nullable=True))
|
|
op.drop_index(op.f('ix_channels_channel_id'), table_name='channels')
|
|
op.create_index(op.f('ix_channels_channel_id'), 'channels', ['channel_id'], unique=False)
|
|
op.create_index('idx_user_channel', 'channels', ['user_id', 'channel_id'], unique=True)
|
|
op.create_index(op.f('ix_channels_user_id'), 'channels', ['user_id'], unique=False)
|
|
op.create_foreign_key(None, 'channels', 'users', ['user_id'], ['id'])
|
|
op.drop_column('channels', 'last_fetched')
|
|
op.add_column('video_entries', sa.Column('video_id', sa.String(length=50), nullable=False))
|
|
op.add_column('video_entries', sa.Column('video_url', sa.String(length=500), nullable=False))
|
|
op.add_column('video_entries', sa.Column('thumbnail_url', sa.String(length=500), nullable=True))
|
|
op.add_column('video_entries', sa.Column('description', sa.Text(), nullable=True))
|
|
op.add_column('video_entries', sa.Column('published_at', sa.DateTime(), nullable=False))
|
|
op.create_index('idx_published_at', 'video_entries', ['published_at'], unique=False)
|
|
op.create_index('idx_video_id_channel', 'video_entries', ['video_id', 'channel_id'], unique=True)
|
|
op.create_index(op.f('ix_video_entries_published_at'), 'video_entries', ['published_at'], unique=False)
|
|
op.create_index(op.f('ix_video_entries_video_id'), 'video_entries', ['video_id'], unique=False)
|
|
op.create_index(op.f('ix_video_entries_video_url'), 'video_entries', ['video_url'], unique=False)
|
|
op.drop_column('video_entries', 'link')
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.add_column('video_entries', sa.Column('link', sa.VARCHAR(length=500), nullable=False))
|
|
op.drop_index(op.f('ix_video_entries_video_url'), table_name='video_entries')
|
|
op.drop_index(op.f('ix_video_entries_video_id'), table_name='video_entries')
|
|
op.drop_index(op.f('ix_video_entries_published_at'), table_name='video_entries')
|
|
op.drop_index('idx_video_id_channel', table_name='video_entries')
|
|
op.drop_index('idx_published_at', table_name='video_entries')
|
|
op.drop_column('video_entries', 'published_at')
|
|
op.drop_column('video_entries', 'description')
|
|
op.drop_column('video_entries', 'thumbnail_url')
|
|
op.drop_column('video_entries', 'video_url')
|
|
op.drop_column('video_entries', 'video_id')
|
|
op.add_column('channels', sa.Column('last_fetched', sa.DATETIME(), nullable=False))
|
|
op.drop_constraint(None, 'channels', type_='foreignkey')
|
|
op.drop_index(op.f('ix_channels_user_id'), table_name='channels')
|
|
op.drop_index('idx_user_channel', table_name='channels')
|
|
op.drop_index(op.f('ix_channels_channel_id'), table_name='channels')
|
|
op.create_index(op.f('ix_channels_channel_id'), 'channels', ['channel_id'], unique=1)
|
|
op.drop_column('channels', 'last_fetched_at')
|
|
op.drop_column('channels', 'rss_url')
|
|
op.drop_column('channels', 'user_id')
|
|
op.drop_index(op.f('ix_users_username'), table_name='users')
|
|
op.drop_index(op.f('ix_users_email'), table_name='users')
|
|
op.drop_table('users')
|
|
# ### end Alembic commands ###
|