16 lines
521 B
SQL
16 lines
521 B
SQL
ALTER TABLE public.faq_items
|
|
ADD COLUMN IF NOT EXISTS best_reply_id uuid;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint WHERE conname = 'faq_items_best_reply_id_fkey'
|
|
) THEN
|
|
ALTER TABLE ONLY public.faq_items
|
|
ADD CONSTRAINT faq_items_best_reply_id_fkey
|
|
FOREIGN KEY (best_reply_id) REFERENCES public.faq_replies(id) ON DELETE SET NULL;
|
|
END IF;
|
|
END $$;
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_faq_items_best_reply_id ON public.faq_items USING btree (best_reply_id);
|