Fix blog: add page_configs migration, fix stale cart reference in ghost_sync
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 43s

- Add 0003_add_page_configs.py migration to create table in db_blog
- Fix ghost_sync.py: fetch_data("cart", "page-config-ensure") → "blog"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 09:25:19 +00:00
parent fe34ea8e5b
commit 96b02d93df
2 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
"""Add page_configs table — moved from cart service to blog.
Revision ID: blog_0003
Revises: blog_0002
Create Date: 2026-02-27
"""
import sqlalchemy as sa
from alembic import op
revision = "blog_0003"
down_revision = "blog_0002"
branch_labels = None
depends_on = None
def _table_exists(conn, name):
result = conn.execute(sa.text(
"SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name=:t"
), {"t": name})
return result.scalar() is not None
def upgrade():
if _table_exists(op.get_bind(), "page_configs"):
return
op.create_table(
"page_configs",
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
sa.Column("container_type", sa.String(32), nullable=False, server_default=sa.text("'page'")),
sa.Column("container_id", sa.Integer, nullable=False),
sa.Column("features", sa.JSON, nullable=False, server_default="{}"),
sa.Column("sumup_merchant_code", sa.String(64), nullable=True),
sa.Column("sumup_api_key", sa.Text, nullable=True),
sa.Column("sumup_checkout_prefix", sa.String(64), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True),
)
def downgrade():
op.drop_table("page_configs")

View File

@@ -248,10 +248,10 @@ async def _upsert_post(sess: AsyncSession, gp: Dict[str, Any], author_map: Dict[
finally:
sess.autoflush = old_autoflush
# Auto-create PageConfig for pages (lives in db_cart, accessed via internal API)
# Auto-create PageConfig for pages (blog now owns this table)
if obj.is_page:
await fetch_data(
"cart", "page-config-ensure",
"blog", "page-config-ensure",
params={"container_type": "page", "container_id": obj.id},
required=False,
)