130 lines
6.6 KiB
Python
130 lines
6.6 KiB
Python
"""新增素材前测表和素材表字段
|
||
|
||
Revision ID: 9ff32ea1bdeb
|
||
Revises: 9216bca75ccf
|
||
Create Date: 2026-06-16 17:15:26.964505
|
||
"""
|
||
from typing import Sequence, Union
|
||
|
||
from alembic import op
|
||
import sqlalchemy as sa
|
||
|
||
|
||
# revision identifiers, used by Alembic.
|
||
revision: str = '9ff32ea1bdeb'
|
||
down_revision: Union[str, None] = '9216bca75ccf'
|
||
branch_labels: Union[str, Sequence[str], None] = None
|
||
depends_on: Union[str, Sequence[str], None] = None
|
||
|
||
|
||
def upgrade() -> None:
|
||
# ### commands auto generated by Alembic - please adjust! ###
|
||
op.add_column('pre_test_template', sa.Column('note', sa.Text(), nullable=True, comment='模板备注'))
|
||
op.alter_column('pre_test_template', 'platform',
|
||
existing_type=sa.VARCHAR(length=32),
|
||
nullable=True,
|
||
existing_comment='投放平台(AD/QIANCHUAN/LOCAL)')
|
||
op.alter_column('pre_test_template', 'external_action',
|
||
existing_type=sa.VARCHAR(length=64),
|
||
nullable=True,
|
||
existing_comment='转化目标')
|
||
op.alter_column('pre_test_template', 'audience_gender',
|
||
existing_type=sa.VARCHAR(length=16),
|
||
nullable=True,
|
||
existing_comment='性别(ALL/MALE/FEMALE)')
|
||
op.alter_column('pre_test_template', 'audience_age',
|
||
existing_type=sa.TEXT(),
|
||
comment='受众年龄,JSON数组, 格式:[ALL,18-23, 24-30, 31-40, 41-49, 50+]',
|
||
existing_comment='受众年龄,JSON数组',
|
||
existing_nullable=True)
|
||
op.alter_column('pre_test_template', 'audience_network',
|
||
existing_type=sa.TEXT(),
|
||
comment='网络类型,JSON数组, 格式:[ALL,5G,4G,3G,2G,WIFI]',
|
||
existing_comment='网络类型,JSON数组',
|
||
existing_nullable=True)
|
||
op.alter_column('pre_test_template', 'pricing_type',
|
||
existing_type=sa.VARCHAR(length=16),
|
||
nullable=True,
|
||
existing_comment='出价类型(OCPC/CPA/OCPM)')
|
||
op.alter_column('pre_test_template', 'cost_cap',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=True,
|
||
existing_comment='是否最优成本出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'target_cost',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=True,
|
||
existing_comment='是否稳定成本出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'nobid',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=True,
|
||
existing_comment='是否最大转化出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'is_default',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=True,
|
||
existing_comment='是否默认模板')
|
||
op.drop_column('pre_test_template', 'status')
|
||
op.drop_column('pre_test_template', 'description')
|
||
op.add_column('resources_material', sa.Column('task_id', sa.String(length=32), nullable=True, comment='前测任务id'))
|
||
op.add_column('resources_material', sa.Column('note', sa.Text(), nullable=True, comment='前测失败备注或者其他备注'))
|
||
op.add_column('resources_material', sa.Column('status', sa.String(length=16), nullable=True, comment='前测状态(FAILED/PENDING/SUCCESS)'))
|
||
op.add_column('resources_material', sa.Column('pre_result', sa.Text(), nullable=True, comment='前测结果,JSON数组对象'))
|
||
op.add_column('resources_material', sa.Column('pre_test_template_id', sa.String(length=32), nullable=True, comment='前测模板id'))
|
||
op.create_index(op.f('ix_resources_material_task_id'), 'resources_material', ['task_id'], unique=False)
|
||
# ### end Alembic commands ###
|
||
|
||
|
||
def downgrade() -> None:
|
||
# ### commands auto generated by Alembic - please adjust! ###
|
||
op.drop_index(op.f('ix_resources_material_task_id'), table_name='resources_material')
|
||
op.drop_column('resources_material', 'pre_test_template_id')
|
||
op.drop_column('resources_material', 'pre_result')
|
||
op.drop_column('resources_material', 'status')
|
||
op.drop_column('resources_material', 'note')
|
||
op.drop_column('resources_material', 'task_id')
|
||
op.add_column('pre_test_template', sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True, comment='模板描述'))
|
||
op.add_column('pre_test_template', sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=False, comment='状态(0=禁用,1=启用)'))
|
||
op.alter_column('pre_test_template', 'is_default',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=False,
|
||
existing_comment='是否默认模板')
|
||
op.alter_column('pre_test_template', 'nobid',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=False,
|
||
existing_comment='是否最大转化出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'target_cost',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=False,
|
||
existing_comment='是否稳定成本出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'cost_cap',
|
||
existing_type=sa.BOOLEAN(),
|
||
nullable=False,
|
||
existing_comment='是否最优成本出价(仅AD支持)')
|
||
op.alter_column('pre_test_template', 'pricing_type',
|
||
existing_type=sa.VARCHAR(length=16),
|
||
nullable=False,
|
||
existing_comment='出价类型(OCPC/CPA/OCPM)')
|
||
op.alter_column('pre_test_template', 'audience_network',
|
||
existing_type=sa.TEXT(),
|
||
comment='网络类型,JSON数组',
|
||
existing_comment='网络类型,JSON数组, 格式:[ALL,5G,4G,3G,2G,WIFI]',
|
||
existing_nullable=True)
|
||
op.alter_column('pre_test_template', 'audience_age',
|
||
existing_type=sa.TEXT(),
|
||
comment='受众年龄,JSON数组',
|
||
existing_comment='受众年龄,JSON数组, 格式:[ALL,18-23, 24-30, 31-40, 41-49, 50+]',
|
||
existing_nullable=True)
|
||
op.alter_column('pre_test_template', 'audience_gender',
|
||
existing_type=sa.VARCHAR(length=16),
|
||
nullable=False,
|
||
existing_comment='性别(ALL/MALE/FEMALE)')
|
||
op.alter_column('pre_test_template', 'external_action',
|
||
existing_type=sa.VARCHAR(length=64),
|
||
nullable=False,
|
||
existing_comment='转化目标')
|
||
op.alter_column('pre_test_template', 'platform',
|
||
existing_type=sa.VARCHAR(length=32),
|
||
nullable=False,
|
||
existing_comment='投放平台(AD/QIANCHUAN/LOCAL)')
|
||
op.drop_column('pre_test_template', 'note')
|
||
# ### end Alembic commands ###
|