Split cart into 4 microservices: relations, likes, orders, page-config→blog
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Phase 1 - Relations service (internal): owns ContainerRelation, exposes get-children data + attach/detach-child actions. Retargeted events, blog, market callers from cart to relations. Phase 2 - Likes service (internal): unified Like model replaces ProductLike and PostLike with generic target_type/target_slug/target_id. Exposes is-liked, liked-slugs, liked-ids data + toggle action. Phase 3 - PageConfig → blog: moved ownership to blog with direct DB queries, removed proxy endpoints from cart. Phase 4 - Orders service (public): owns Order/OrderItem + SumUp checkout flow. Cart checkout now delegates to orders via create-order action. Webhook/return routes and reconciliation moved to orders. Phase 5 - Infrastructure: docker-compose, deploy.sh, Dockerfiles updated for all 3 new services. Added orders_url helper and factory model imports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
orders/alembic/env.py
Normal file
12
orders/alembic/env.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from alembic import context
|
||||
from shared.db.alembic_env import run_alembic
|
||||
|
||||
MODELS = [
|
||||
"shared.models.order",
|
||||
]
|
||||
|
||||
TABLES = frozenset({
|
||||
"orders", "order_items",
|
||||
})
|
||||
|
||||
run_alembic(context.config, MODELS, TABLES)
|
||||
67
orders/alembic/versions/0001_initial.py
Normal file
67
orders/alembic/versions/0001_initial.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""Initial orders tables
|
||||
|
||||
Revision ID: orders_0001
|
||||
Revises: None
|
||||
Create Date: 2026-02-27
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "orders_0001"
|
||||
down_revision = None
|
||||
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 not _table_exists(op.get_bind(), "orders"):
|
||||
op.create_table(
|
||||
"orders",
|
||||
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
||||
sa.Column("user_id", sa.Integer, nullable=True),
|
||||
sa.Column("session_id", sa.String(64), nullable=True),
|
||||
sa.Column("page_config_id", sa.Integer, nullable=True),
|
||||
sa.Column("status", sa.String(32), nullable=False, server_default="pending"),
|
||||
sa.Column("currency", sa.String(16), nullable=False, server_default="GBP"),
|
||||
sa.Column("total_amount", sa.Numeric(12, 2), nullable=False),
|
||||
sa.Column("description", sa.Text, nullable=True),
|
||||
sa.Column("sumup_reference", sa.String(255), nullable=True),
|
||||
sa.Column("sumup_checkout_id", sa.String(128), nullable=True),
|
||||
sa.Column("sumup_status", sa.String(32), nullable=True),
|
||||
sa.Column("sumup_hosted_url", sa.Text, 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()),
|
||||
)
|
||||
op.create_index("ix_orders_session_id", "orders", ["session_id"])
|
||||
op.create_index("ix_orders_page_config_id", "orders", ["page_config_id"])
|
||||
op.create_index("ix_orders_description", "orders", ["description"], postgresql_using="hash")
|
||||
op.create_index("ix_orders_sumup_reference", "orders", ["sumup_reference"])
|
||||
op.create_index("ix_orders_sumup_checkout_id", "orders", ["sumup_checkout_id"])
|
||||
|
||||
if not _table_exists(op.get_bind(), "order_items"):
|
||||
op.create_table(
|
||||
"order_items",
|
||||
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
||||
sa.Column("order_id", sa.Integer, sa.ForeignKey("orders.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("product_id", sa.Integer, nullable=False),
|
||||
sa.Column("product_title", sa.String(512), nullable=True),
|
||||
sa.Column("product_slug", sa.String(512), nullable=True),
|
||||
sa.Column("product_image", sa.Text, nullable=True),
|
||||
sa.Column("quantity", sa.Integer, nullable=False, server_default="1"),
|
||||
sa.Column("unit_price", sa.Numeric(12, 2), nullable=False),
|
||||
sa.Column("currency", sa.String(16), nullable=False, server_default="GBP"),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table("order_items")
|
||||
op.drop_table("orders")
|
||||
Reference in New Issue
Block a user