-- =============================================================================
-- MIGRATION: Drop customerId FKs that reference customer.customers
-- Idempotent — safe to re-execute
--
-- Storefront auth users live in admin.users (AuthRepository), but the init
-- migration added FKs from carts/checkout_sessions/orders.customerId to
-- customer.customers — a table nothing populates. Every findOrCreateCart /
-- checkout-session / order insert therefore failed with a FK violation (500).
-- schema.prisma declares customerId as a plain nullable string with no
-- relation on all three models, so dropping the constraints removes the
-- drift between the database and the Prisma schema.
-- =============================================================================

ALTER TABLE "cart"."carts" DROP CONSTRAINT IF EXISTS "carts_customerId_fkey";
ALTER TABLE "cart"."checkout_sessions" DROP CONSTRAINT IF EXISTS "checkout_sessions_customerId_fkey";
ALTER TABLE "sales"."orders" DROP CONSTRAINT IF EXISTS "orders_customerId_fkey";
