mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
14 lines
488 B
SQL
14 lines
488 B
SQL
-- Handle existing unique constraint gracefully
|
|
DO $$
|
|
BEGIN
|
|
-- Check if constraint already exists
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM information_schema.table_constraints
|
|
WHERE constraint_name = 'unique_comment_user_reaction'
|
|
AND table_name = 'comment_reactions'
|
|
) THEN
|
|
-- Try to add constraint, ignore if it exists
|
|
ALTER TABLE comment_reactions ADD CONSTRAINT unique_comment_user_reaction UNIQUE (comment_id, user_id);
|
|
END IF;
|
|
END $$;
|