1
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""add collection_records
|
||||
|
||||
Revision ID: b3c7d9e21f4a
|
||||
Revises: d659ecc1b6e7
|
||||
Create Date: 2026-10-17 12:00:00.000000
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
revision = 'b3c7d9e21f4a'
|
||||
down_revision = 'd659ecc1b6e7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table('collection_records',
|
||||
sa.Column('id', mysql.BIGINT(unsigned=True), autoincrement=True, nullable=False),
|
||||
sa.Column('source_key', sa.String(length=50), nullable=False, comment='内容源标识'),
|
||||
sa.Column('source_id', mysql.BIGINT(unsigned=True), nullable=False, comment='源站内容 id'),
|
||||
sa.Column('series_id', mysql.BIGINT(unsigned=True), nullable=False, comment='本站系列 id'),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('uk_source', 'collection_records', ['source_key', 'source_id'], unique=True)
|
||||
op.create_index('idx_record_series', 'collection_records', ['series_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index('idx_record_series', table_name='collection_records')
|
||||
op.drop_index('uk_source', table_name='collection_records')
|
||||
op.drop_table('collection_records')
|
||||
@@ -0,0 +1,37 @@
|
||||
"""add collection_sources + collection_records.video_id
|
||||
|
||||
Revision ID: c8f2a15e93b7
|
||||
Revises: b3c7d9e21f4a
|
||||
Create Date: 2026-10-17 13:00:00.000000
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
revision = 'c8f2a15e93b7'
|
||||
down_revision = 'b3c7d9e21f4a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table('collection_sources',
|
||||
sa.Column('id', mysql.BIGINT(unsigned=True), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.String(length=50), nullable=False, comment='分类名'),
|
||||
sa.Column('list_url', sa.String(length=500), nullable=False, comment='列表URL模板, {{page}}为页码占位'),
|
||||
sa.Column('category_id', mysql.INTEGER(unsigned=True), nullable=False, comment='本站分类id'),
|
||||
sa.Column('status', mysql.SMALLINT(), nullable=False, server_default='1', comment='1启用 0停用'),
|
||||
sa.Column('last_sync_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('list_url', name='uk_list_url')
|
||||
)
|
||||
op.add_column('collection_records', sa.Column('video_id', mysql.BIGINT(unsigned=True), nullable=True, comment='本站视频id(单视频类采集)'))
|
||||
op.alter_column('collection_records', 'series_id', existing_type=mysql.BIGINT(unsigned=True), nullable=True)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.alter_column('collection_records', 'series_id', existing_type=mysql.BIGINT(unsigned=True), nullable=False)
|
||||
op.drop_column('collection_records', 'video_id')
|
||||
op.drop_table('collection_sources')
|
||||
Reference in New Issue
Block a user