18 lines
572 B
SQL
18 lines
572 B
SQL
-- Remove duplicate records from tablo_invites table
|
|
-- Keep only the earliest record (lowest id) for each (tablo_id, invited_email) combination
|
|
DELETE FROM tablo_invites
|
|
WHERE id NOT IN (
|
|
SELECT MIN(id)
|
|
FROM tablo_invites
|
|
GROUP BY tablo_id, invited_email
|
|
);
|
|
|
|
-- Drop existing constraint if it exists (to avoid errors)
|
|
ALTER TABLE tablo_invites
|
|
DROP CONSTRAINT IF EXISTS unique_tablo_invitation;
|
|
|
|
-- Add unique constraint to prevent duplicate invitations
|
|
ALTER TABLE tablo_invites
|
|
ADD CONSTRAINT unique_tablo_invitation
|
|
UNIQUE (tablo_id, invited_email);
|
|
|