Introduce page_configs table for per-page feature flags (calendar, market) and future SumUp credentials. Add page_config relationship to Post model. Remove duplicate CartItem definition from cart_item.py (canonical stays in market.py). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import Integer, String, Text, DateTime, ForeignKey, func, JSON
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from db.base import Base
|
|
|
|
|
|
class PageConfig(Base):
|
|
__tablename__ = "page_configs"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
post_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("posts.id", ondelete="CASCADE"),
|
|
unique=True,
|
|
nullable=False,
|
|
)
|
|
|
|
features: Mapped[dict] = mapped_column(
|
|
JSON, nullable=False, server_default="{}"
|
|
)
|
|
|
|
# Phase 3: per-page SumUp credentials (NULL until configured)
|
|
sumup_merchant_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
|
sumup_api_key: Mapped[Optional[str]] = mapped_column(Text(), nullable=True)
|
|
sumup_checkout_prefix: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False, server_default=func.now()
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False, server_default=func.now()
|
|
)
|
|
deleted_at: Mapped[Optional[datetime]] = mapped_column(
|
|
DateTime(timezone=True), nullable=True
|
|
)
|
|
|
|
post: Mapped["Post"] = relationship(
|
|
"Post", back_populates="page_config", foreign_keys=[post_id]
|
|
)
|