mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-05 00:48:16 +01:00
- Add migration 052 to update marketplace_orders CHECK constraint: 'pending' → 'pending_payment' (matches ORDER_STATUS config) - Fix Payrexx webhook setting invalid 'paid' status on service appointments — use APPOINTMENT_STATUS.CONFIRMED instead - Fix appointment pay route referencing non-existent 'approved' status and setting invalid 'paid' — use APPOINTMENT_STATUS.COMPLETED - Use APPOINTMENT_STATUS constants instead of PAYMENT_STATUS for appointment status updates (type safety) These mismatches would cause CHECK constraint violations at runtime when creating marketplace orders or processing payment webhooks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
14 lines
797 B
SQL
14 lines
797 B
SQL
-- Fix marketplace_orders status constraint to accept 'pending_payment' instead of 'pending'
|
|
-- The application code uses 'pending_payment' to distinguish orders awaiting payment
|
|
-- from other states. The original migration (031) used 'pending' which doesn't match.
|
|
|
|
-- Drop the old constraint
|
|
ALTER TABLE marketplace_orders DROP CONSTRAINT IF EXISTS marketplace_orders_status_check;
|
|
|
|
-- Add updated constraint with 'pending_payment' instead of 'pending'
|
|
ALTER TABLE marketplace_orders ADD CONSTRAINT marketplace_orders_status_check
|
|
CHECK (status IN ('pending_payment', 'paid', 'shipped', 'delivered', 'completed', 'cancelled', 'refunded'));
|
|
|
|
-- Update any existing rows that have 'pending' to 'pending_payment'
|
|
UPDATE marketplace_orders SET status = 'pending_payment' WHERE status = 'pending';
|