Fix API token mapping and add extensive debug logging

- 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>
This commit is contained in:
dwindown
2026-01-02 14:31:23 +07:00
parent 219ad11202
commit 06d6845456
5 changed files with 249 additions and 4 deletions

View File

@@ -0,0 +1,26 @@
-- ============================================================================
-- 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 $$;