chore: import WonderQ project
This commit is contained in:
commit
f5a9e4403a
452 files changed
+34173
No files matched your search
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Initial SQLAlchemy schema.
|
||||
|
||||
Revision ID: 0001_initial_schema
|
||||
Revises:
|
||||
Create Date: 2026-06-30
|
||||
"""
|
||||
|
||||
from alembic import context, op
|
||||
from sqlalchemy import inspect
|
||||
from app.database import Base
|
||||
from app import models # noqa: F401
|
||||
|
||||
|
||||
revision = "0001_initial_schema"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if context.is_offline_mode():
|
||||
Base.metadata.create_all(bind=bind, checkfirst=False)
|
||||
return
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
for table in Base.metadata.sorted_tables:
|
||||
if table.name not in existing_tables:
|
||||
table.create(bind)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
Base.metadata.drop_all(bind=op.get_bind(), checkfirst=not context.is_offline_mode())
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Add map image module table.
|
||||
|
||||
Revision ID: 0002_add_map_image
|
||||
Revises: 0001_initial_schema
|
||||
Create Date: 2026-07-01
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import inspect
|
||||
from app.models import MapImage
|
||||
|
||||
|
||||
revision = "0002_add_map_image"
|
||||
down_revision = "0001_initial_schema"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "MapImage" not in set(inspect(bind).get_table_names()):
|
||||
MapImage.__table__.create(bind)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "MapImage" in set(inspect(bind).get_table_names()):
|
||||
MapImage.__table__.drop(bind)
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Add campaign display fields.
|
||||
|
||||
Revision ID: 0003_campaign_display_fields
|
||||
Revises: 0002_add_map_image
|
||||
Create Date: 2026-07-02
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
revision = "0003_campaign_display_fields"
|
||||
down_revision = "0002_add_map_image"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "Campaign" not in set(inspect(bind).get_table_names()):
|
||||
return
|
||||
|
||||
columns = {column["name"] for column in inspect(bind).get_columns("Campaign")}
|
||||
if "priceAmount" not in columns:
|
||||
op.add_column("Campaign", sa.Column("priceAmount", sa.Integer(), nullable=True))
|
||||
if "priceUnit" not in columns:
|
||||
op.add_column("Campaign", sa.Column("priceUnit", sa.String(), nullable=True))
|
||||
if "tags" not in columns:
|
||||
op.add_column(
|
||||
"Campaign",
|
||||
sa.Column(
|
||||
"tags",
|
||||
postgresql.ARRAY(sa.String()),
|
||||
nullable=False,
|
||||
server_default=sa.text("'{}'::varchar[]"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "Campaign" not in set(inspect(bind).get_table_names()):
|
||||
return
|
||||
|
||||
columns = {column["name"] for column in inspect(bind).get_columns("Campaign")}
|
||||
if "tags" in columns:
|
||||
op.drop_column("Campaign", "tags")
|
||||
if "priceUnit" in columns:
|
||||
op.drop_column("Campaign", "priceUnit")
|
||||
if "priceAmount" in columns:
|
||||
op.drop_column("Campaign", "priceAmount")
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Add route section configuration.
|
||||
|
||||
Revision ID: 0004_route_sections
|
||||
Revises: 0003_campaign_display_fields
|
||||
Create Date: 2026-07-02
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
|
||||
|
||||
revision = "0004_route_sections"
|
||||
down_revision = "0003_campaign_display_fields"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
|
||||
if "RouteSection" not in existing_tables:
|
||||
op.create_table(
|
||||
"RouteSection",
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("subtitle", 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"),
|
||||
)
|
||||
|
||||
if "RouteSectionProduct" not in existing_tables:
|
||||
op.create_table(
|
||||
"RouteSectionProduct",
|
||||
sa.Column("sectionId", sa.String(), nullable=False),
|
||||
sa.Column("productId", sa.String(), nullable=False),
|
||||
sa.Column("sortOrder", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.ForeignKeyConstraint(["productId"], ["Product.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["sectionId"], ["RouteSection.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("sectionId", "productId"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
if "RouteSectionProduct" in existing_tables:
|
||||
op.drop_table("RouteSectionProduct")
|
||||
if "RouteSection" in existing_tables:
|
||||
op.drop_table("RouteSection")
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Add hotel and vehicle site modules.
|
||||
|
||||
Revision ID: 0005_hotel_vehicle_modules
|
||||
Revises: 0004_route_sections
|
||||
Create Date: 2026-07-03
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
|
||||
|
||||
revision = "0005_hotel_vehicle_modules"
|
||||
down_revision = "0004_route_sections"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _create_card_table(table_name: str) -> None:
|
||||
op.create_table(
|
||||
table_name,
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("description", sa.Text(), 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 upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
if "HotelGroup" not in existing_tables:
|
||||
_create_card_table("HotelGroup")
|
||||
if "VehicleOption" not in existing_tables:
|
||||
_create_card_table("VehicleOption")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
if "VehicleOption" in existing_tables:
|
||||
op.drop_table("VehicleOption")
|
||||
if "HotelGroup" in existing_tables:
|
||||
op.drop_table("HotelGroup")
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Add offer display fields to hotel groups.
|
||||
|
||||
Revision ID: 0006_hotel_group_offer_fields
|
||||
Revises: 0005_hotel_vehicle_modules
|
||||
Create Date: 2026-07-03
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
revision = "0006_hotel_group_offer_fields"
|
||||
down_revision = "0005_hotel_vehicle_modules"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "HotelGroup" not in set(inspect(bind).get_table_names()):
|
||||
return
|
||||
|
||||
columns = {column["name"] for column in inspect(bind).get_columns("HotelGroup")}
|
||||
if "coverImage" not in columns:
|
||||
op.add_column("HotelGroup", sa.Column("coverImage", sa.String(), nullable=True))
|
||||
op.execute('UPDATE "HotelGroup" SET "coverImage" = image WHERE "coverImage" IS NULL')
|
||||
if "priceAmount" not in columns:
|
||||
op.add_column("HotelGroup", sa.Column("priceAmount", sa.Integer(), nullable=True))
|
||||
if "priceUnit" not in columns:
|
||||
op.add_column("HotelGroup", sa.Column("priceUnit", sa.String(), nullable=True, server_default="起/晚"))
|
||||
if "tags" not in columns:
|
||||
op.add_column(
|
||||
"HotelGroup",
|
||||
sa.Column(
|
||||
"tags",
|
||||
postgresql.ARRAY(sa.String()),
|
||||
nullable=False,
|
||||
server_default=sa.text("'{}'::varchar[]"),
|
||||
),
|
||||
)
|
||||
if "status" not in columns:
|
||||
op.add_column("HotelGroup", sa.Column("status", sa.String(), nullable=False, server_default="published"))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "HotelGroup" not in set(inspect(bind).get_table_names()):
|
||||
return
|
||||
|
||||
columns = {column["name"] for column in inspect(bind).get_columns("HotelGroup")}
|
||||
for column_name in ["status", "tags", "priceUnit", "priceAmount", "coverImage"]:
|
||||
if column_name in columns:
|
||||
op.drop_column("HotelGroup", column_name)
|
||||
@@ -0,0 +1,64 @@
|
||||
"""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")
|
||||
@@ -0,0 +1,106 @@
|
||||
"""Add demand page configurable modules.
|
||||
|
||||
Revision ID: 0008_demand_page_modules
|
||||
Revises: 0007_destination_page_modules
|
||||
Create Date: 2026-07-07
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
revision = "0008_demand_page_modules"
|
||||
down_revision = "0007_destination_page_modules"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
|
||||
if "DemandHero" not in existing_tables:
|
||||
op.create_table(
|
||||
"DemandHero",
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("kicker", sa.String(), nullable=True),
|
||||
sa.Column("description", sa.Text(), nullable=True),
|
||||
sa.Column("steps", postgresql.ARRAY(sa.String()), nullable=False, server_default=sa.text("'{}'")),
|
||||
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"),
|
||||
)
|
||||
|
||||
if "DemandFeatureCard" not in existing_tables:
|
||||
op.create_table(
|
||||
"DemandFeatureCard",
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("description", 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"),
|
||||
)
|
||||
|
||||
if "DemandForm" not in existing_tables:
|
||||
op.create_table(
|
||||
"DemandForm",
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("destinationLabel", sa.String(), nullable=False, server_default="目的地/玩法"),
|
||||
sa.Column("destinationPlaceholder", sa.String(), nullable=True),
|
||||
sa.Column("phoneLabel", sa.String(), nullable=False, server_default="联系方式"),
|
||||
sa.Column("phonePlaceholder", sa.String(), nullable=True),
|
||||
sa.Column("noteLabel", sa.String(), nullable=False, server_default="补充说明"),
|
||||
sa.Column("notePlaceholder", sa.String(), nullable=True),
|
||||
sa.Column("submitLabel", sa.String(), nullable=False, server_default="提交出行需求"),
|
||||
sa.Column("chips", postgresql.ARRAY(sa.String()), nullable=False, server_default=sa.text("'{}'")),
|
||||
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"),
|
||||
)
|
||||
|
||||
if "DemandRecommendation" not in existing_tables:
|
||||
op.create_table(
|
||||
"DemandRecommendation",
|
||||
sa.Column("id", sa.String(), nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("subtitle", 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"),
|
||||
)
|
||||
|
||||
if "DemandRecommendationProduct" not in existing_tables:
|
||||
op.create_table(
|
||||
"DemandRecommendationProduct",
|
||||
sa.Column("recommendationId", sa.String(), nullable=False),
|
||||
sa.Column("productId", sa.String(), nullable=False),
|
||||
sa.Column("sortOrder", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.ForeignKeyConstraint(["productId"], ["Product.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["recommendationId"], ["DemandRecommendation.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("recommendationId", "productId"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
existing_tables = set(inspect(bind).get_table_names())
|
||||
for table_name in [
|
||||
"DemandRecommendationProduct",
|
||||
"DemandRecommendation",
|
||||
"DemandForm",
|
||||
"DemandFeatureCard",
|
||||
"DemandHero",
|
||||
]:
|
||||
if table_name in existing_tables:
|
||||
op.drop_table(table_name)
|
||||
Reference in new issue
Block a user