"""create resources_material table Revision ID: 906b205a5a40 Revises: 0a861ba0828b Create Date: 2026-06-12 15:47:28.291461 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa revision: str = '906b205a5a40' down_revision: Union[str, None] = '0a861ba0828b' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table('resources_material', sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False, comment='主键'), sa.Column('oauth_id', sa.String(length=64), nullable=False, comment='授权表user_oauth自增id'), sa.Column('advertiser_id', sa.String(length=64), nullable=True, comment='广告主id'), sa.Column('target_table', sa.String(length=64), nullable=True, comment='资源表名称'), sa.Column('target_id', sa.String(length=64), nullable=True, comment='资源表id'), sa.Column('material_id', sa.String(length=64), nullable=True, comment='素材id'), sa.Column('upload_id', sa.String(length=128), nullable=True, comment='上传资源平台id,图片id,视频id'), sa.Column('resource_type', sa.String(length=16), nullable=True, comment='资源类型,image或者video'), sa.Column('user_id', sa.String(length=64), nullable=True, comment='用户登录id'), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_resources_material_advertiser_id'), 'resources_material', ['advertiser_id'], unique=False) op.create_index(op.f('ix_resources_material_deleted_at'), 'resources_material', ['deleted_at'], unique=False) op.create_index(op.f('ix_resources_material_material_id'), 'resources_material', ['material_id'], unique=False) op.create_index(op.f('ix_resources_material_oauth_id'), 'resources_material', ['oauth_id'], unique=False) op.create_index(op.f('ix_resources_material_resource_type'), 'resources_material', ['resource_type'], unique=False) op.create_index(op.f('ix_resources_material_target_id'), 'resources_material', ['target_id'], unique=False) op.create_index(op.f('ix_resources_material_target_table'), 'resources_material', ['target_table'], unique=False) op.create_index(op.f('ix_resources_material_upload_id'), 'resources_material', ['upload_id'], unique=False) op.create_index(op.f('ix_resources_material_user_id'), 'resources_material', ['user_id'], unique=False) def downgrade() -> None: op.drop_index(op.f('ix_resources_material_user_id'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_upload_id'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_target_table'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_target_id'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_resource_type'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_oauth_id'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_material_id'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_deleted_at'), table_name='resources_material') op.drop_index(op.f('ix_resources_material_advertiser_id'), table_name='resources_material') op.drop_table('resources_material')