refactor(migrations): squash 75 migrations into 12 per-module initial migrations

The old migration chain was broken (downgrade path through vendor->merchant
rename made rollbacks impossible). This squashes everything into fresh
per-module migrations with zero schema drift, verified by autogenerate.

Changes:
- Replace 75 accumulated migrations with 12 per-module initial migrations
  (core, billing, catalog, marketplace, cms, customers, orders, inventory,
  cart, messaging, loyalty, dev_tools) in a linear chain
- Fix make db-reset to use SQL DROP SCHEMA instead of alembic downgrade base
- Enable migration autodiscovery for all modules (migrations_path in definitions)
- Rewrite alembic/env.py to import all 75 model tables across 13 modules
- Fix AdminNotification import (was incorrectly from tenancy, now from messaging)
- Update squash_migrations.py to handle all module migration directories

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 11:51:37 +01:00
parent dad02695f6
commit c3d26e9aa4
111 changed files with 2285 additions and 11723 deletions

View File

@@ -121,11 +121,11 @@ class Product(Base, TimestampMixin):
# === CONSTRAINTS & INDEXES ===
__table_args__ = (
UniqueConstraint(
"store_id", "marketplace_product_id", name="uq_vendor_marketplace_product"
"store_id", "marketplace_product_id", name="uq_store_marketplace_product"
),
Index("idx_product_vendor_active", "store_id", "is_active"),
Index("idx_product_vendor_featured", "store_id", "is_featured"),
Index("idx_product_vendor_sku", "store_id", "store_sku"),
Index("idx_product_store_active", "store_id", "is_active"),
Index("idx_product_store_featured", "store_id", "is_featured"),
Index("idx_product_store_sku", "store_id", "store_sku"),
Index("idx_product_supplier", "supplier", "supplier_product_id"),
)