summaryrefslogblamecommitdiff
path: root/makima/migrations/20250124000000_fix_history_events_owner_fk.sql
blob: 1f97779a9eaadc02daa7ca7f9f4b16e43e911e33 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                   
-- Fix history_events owner_id foreign key
-- The owner_id should reference owners(id), not users(id)
-- This was causing all history event inserts to fail silently

-- Drop the incorrect foreign key constraint
ALTER TABLE history_events
    DROP CONSTRAINT IF EXISTS history_events_owner_id_fkey;

-- Add the correct foreign key constraint referencing owners
ALTER TABLE history_events
    ADD CONSTRAINT history_events_owner_id_fkey
    FOREIGN KEY (owner_id) REFERENCES owners(id) ON DELETE CASCADE;