This commit adds full support for two new destination page modules: a hero banner section and categorized destination regions. Changes include: - New SQLAlchemy models and alembic migration for DestinationHero and DestinationRegion tables - Updated Pydantic SiteConfigPatchIn schema with new optional fields - Integrated admin CRUD support for the new modules - Added default seed data for Guizhou destination regions and hero content - Exposed active modules via public site config API - Added comprehensive test coverage for admin and public endpoints
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""Add destination page configurable modules.
|
|
|
|
Revision ID: 0007_destination_page_modules
|
|
Revises: 0006_hotel_group_offer_fields
|
|
Create Date: 2026-07-07
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import inspect
|
|
|
|
|
|
revision = "0007_destination_page_modules"
|
|
down_revision = "0006_hotel_group_offer_fields"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def _create_destination_hero_table() -> None:
|
|
op.create_table(
|
|
"DestinationHero",
|
|
sa.Column("id", sa.String(), nullable=False),
|
|
sa.Column("title", sa.String(), nullable=False),
|
|
sa.Column("kicker", sa.String(), nullable=True),
|
|
sa.Column("image", sa.String(), nullable=True),
|
|
sa.Column("sortOrder", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("isActive", sa.Boolean(), nullable=False, server_default=sa.true()),
|
|
sa.Column("createdAt", sa.DateTime(), nullable=False),
|
|
sa.Column("updatedAt", sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
|
|
|
|
def _create_destination_region_table() -> None:
|
|
op.create_table(
|
|
"DestinationRegion",
|
|
sa.Column("id", sa.String(), nullable=False),
|
|
sa.Column("label", sa.String(), nullable=False),
|
|
sa.Column("keyword", sa.String(), nullable=True),
|
|
sa.Column("spots", sa.Text(), nullable=True),
|
|
sa.Column("sortOrder", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("isActive", sa.Boolean(), nullable=False, server_default=sa.true()),
|
|
sa.Column("createdAt", sa.DateTime(), nullable=False),
|
|
sa.Column("updatedAt", sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
existing_tables = set(inspect(bind).get_table_names())
|
|
if "DestinationHero" not in existing_tables:
|
|
_create_destination_hero_table()
|
|
if "DestinationRegion" not in existing_tables:
|
|
_create_destination_region_table()
|
|
|
|
|
|
def downgrade() -> None:
|
|
bind = op.get_bind()
|
|
existing_tables = set(inspect(bind).get_table_names())
|
|
if "DestinationRegion" in existing_tables:
|
|
op.drop_table("DestinationRegion")
|
|
if "DestinationHero" in existing_tables:
|
|
op.drop_table("DestinationHero")
|