- Fixed api_token vs mailketing_api_token column mapping - Added comprehensive debug logging to send-auth-otp - Added fallback logic for missing settings fields - Improved error messages for troubleshooting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
27 lines
942 B
SQL
27 lines
942 B
SQL
-- ============================================================================
|
|
-- Fix auth_otps foreign key constraint
|
|
-- ============================================================================
|
|
|
|
-- Drop the foreign key constraint since unconfirmed users might not be fully accessible
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'auth_otps_user_id_fkey'
|
|
) THEN
|
|
ALTER TABLE auth_otps DROP CONSTRAINT auth_otps_user_id_fkey;
|
|
END IF;
|
|
END $$;
|
|
|
|
-- Add a check constraint to ensure user_id is a valid UUID
|
|
ALTER TABLE auth_otps ADD CONSTRAINT auth_otps_user_id_valid
|
|
CHECK (user_id::text ~ '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'::text);
|
|
|
|
COMMENT ON TABLE auth_otps IS 'Stores OTP codes for email verification. No FK constraint to handle unconfirmed users.';
|
|
|
|
-- Return success message
|
|
DO $$
|
|
BEGIN
|
|
RAISE NOTICE 'Foreign key constraint removed from auth_otps table';
|
|
END $$;
|