- 新增后台用车服务配置模块,支持维护服务简介、优势与使用流程 - 新增需求线索管理页面,支持筛选、查看与更新用车线索状态 - 新增小程序用车需求页面,优化登录路径与回跳逻辑 - 优化车型卡片跳转与用车需求提交功能 - 新增服务端API与数据处理逻辑,完善权限校验 - 更新全站配置与API文档,新增相关测试用例
54 lines
2.7 KiB
Python
54 lines
2.7 KiB
Python
"""Add vehicle demand fields and service configuration."""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
revision = "0024_vehicle_demand"
|
|
down_revision = "0023_detail_concierge_advisor"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("Lead", sa.Column("leadType", sa.String(), nullable=False, server_default="general"))
|
|
op.add_column("Lead", sa.Column("contactName", sa.String(), nullable=True))
|
|
op.add_column("Lead", sa.Column("customerId", sa.String(), nullable=True))
|
|
op.add_column("Lead", sa.Column("vehicleDemand", postgresql.JSONB(astext_type=sa.Text()), nullable=True))
|
|
op.create_index("ix_Lead_leadType", "Lead", ["leadType"])
|
|
op.create_index("ix_Lead_customerId", "Lead", ["customerId"])
|
|
op.create_foreign_key("fk_Lead_customerId_Customer", "Lead", "Customer", ["customerId"], ["id"], ondelete="SET NULL")
|
|
op.alter_column("Lead", "leadType", server_default=None)
|
|
|
|
op.create_table(
|
|
"VehicleServiceConfig",
|
|
sa.Column("id", sa.String(), nullable=False),
|
|
sa.Column("introTitle", sa.String(), nullable=False),
|
|
sa.Column("intro", sa.Text(), nullable=False),
|
|
sa.Column("serviceSections", postgresql.JSONB(astext_type=sa.Text()), nullable=False, server_default=sa.text("'[]'::jsonb")),
|
|
sa.Column("advantages", postgresql.JSONB(astext_type=sa.Text()), nullable=False, server_default=sa.text("'[]'::jsonb")),
|
|
sa.Column("processSteps", postgresql.JSONB(astext_type=sa.Text()), nullable=False, server_default=sa.text("'[]'::jsonb")),
|
|
sa.Column("isActive", sa.Boolean(), nullable=False, server_default=sa.text("true")),
|
|
sa.Column("createdAt", sa.DateTime(), nullable=False),
|
|
sa.Column("updatedAt", sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_VehicleServiceConfig_isActive", "VehicleServiceConfig", ["isActive"])
|
|
op.alter_column("VehicleServiceConfig", "serviceSections", server_default=None)
|
|
op.alter_column("VehicleServiceConfig", "advantages", server_default=None)
|
|
op.alter_column("VehicleServiceConfig", "processSteps", server_default=None)
|
|
op.alter_column("VehicleServiceConfig", "isActive", server_default=None)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_VehicleServiceConfig_isActive", table_name="VehicleServiceConfig")
|
|
op.drop_table("VehicleServiceConfig")
|
|
op.drop_constraint("fk_Lead_customerId_Customer", "Lead", type_="foreignkey")
|
|
op.drop_index("ix_Lead_customerId", table_name="Lead")
|
|
op.drop_index("ix_Lead_leadType", table_name="Lead")
|
|
op.drop_column("Lead", "vehicleDemand")
|
|
op.drop_column("Lead", "customerId")
|
|
op.drop_column("Lead", "contactName")
|
|
op.drop_column("Lead", "leadType")
|