Changing video view_count to bigint for popular videos.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-02-08 12:33:27 -07:00
parent 387ef6dfe8
commit a5dee64af2
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 31 additions and 2 deletions

View file

@ -0,0 +1,29 @@
"""Video view_count bigint.
Revision ID: d371333159ab
Revises: b2b9700f5048
Create Date: 2026-02-08
This migration changes the view_count column from INTEGER to BIGINT
to accommodate YouTube videos with view counts exceeding 2,147,483,647.
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd371333159ab'
down_revision = 'b2b9700f5048'
branch_labels = None
depends_on = None
def upgrade():
op.alter_column('video', 'view_count',
existing_type=sa.Integer(),
type_=sa.BigInteger())
def downgrade():
op.alter_column('video', 'view_count',
existing_type=sa.BigInteger(),
type_=sa.Integer())

View file

@ -351,7 +351,7 @@ async def update_view_counts_and_censored(channel_id: int):
with get_db_curs(commit=True) as curs:
# Update the view_count for each video.
stmt = '''
WITH source AS (select * from json_to_recordset(%s::json) as (id text, view_count int))
WITH source AS (select * from json_to_recordset(%s::json) as (id text, view_count bigint))
UPDATE video
SET view_count = s.view_count
FROM source as s

View file

@ -34,7 +34,7 @@ class Video(ModelHelper, Base):
id = Column(Integer, primary_key=True)
source_id = Column(String) # The id from yt-dlp
view_count = Column(Integer) # The view count from the ChannelDownloader (or from initial download)
view_count = Column(BigInteger) # The view count from the ChannelDownloader (or from initial download)
ffprobe_json = deferred(Column(JSONB)) # Data that is fetched once from ffprobe (ffmpeg)
have_comments = Column(Boolean, default=False) # see `get_missing_videos_comments`
comments_failed = Column(Boolean, default=False) # see `get_missing_videos_comments`