← back to Lawyer Directory Builder

migrations/017_fix_message_user_fk.sql

5 lines

-- migration 015 declared messages.user_id as NOT NULL with ON DELETE SET NULL,
-- which contradicts and prevents app_users hard-delete. Make it nullable so the
-- SET NULL behavior actually fires when a user is removed.
ALTER TABLE messages ALTER COLUMN user_id DROP NOT NULL;