Files
AlphaPulse/backend/alembic/versions/20261105_dc3456789012_research_batches.py
T
eezd 89da4df785
Development CI / check-and-build (push) Successful in 3m23s
GitHub Git mirror / mirror (push) Successful in 6s
Development CI / deploy-development (push) Successful in 5s
feat(news): restrict research to local sources and process frozen batches
2026-11-05 20:43:31 +08:00

34 lines
1.6 KiB
Python

"""Persist frozen two-stage research batches without rewriting research history."""
from alembic import op
import sqlalchemy as sa
revision = 'dc3456789012'
down_revision = 'db2345678901'
branch_labels = None
depends_on = None
def upgrade():
op.create_table('news_research_batches',
sa.Column('id', sa.BigInteger(), primary_key=True),
sa.Column('phase', sa.String(20), nullable=False),
sa.Column('cutoff_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True))
op.create_index('ix_news_research_batches_phase', 'news_research_batches', ['phase'])
op.create_table('news_research_batch_packages',
sa.Column('batch_id', sa.BigInteger(), sa.ForeignKey('news_research_batches.id'), primary_key=True),
sa.Column('package_id', sa.BigInteger(), sa.ForeignKey('news_research_packages.id'), primary_key=True),
sa.Column('content_hash', sa.String(64), nullable=False),
sa.Column('state', sa.String(20), nullable=False))
op.create_table('news_research_batch_events',
sa.Column('batch_id', sa.BigInteger(), sa.ForeignKey('news_research_batches.id'), primary_key=True),
sa.Column('event_id', sa.BigInteger(), sa.ForeignKey('news_research_events.id'), primary_key=True),
sa.Column('revision', sa.Integer(), nullable=False),
sa.Column('state', sa.String(20), nullable=False))
def downgrade():
op.drop_table('news_research_batch_events')
op.drop_table('news_research_batch_packages')
op.drop_table('news_research_batches')