mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
15 lines
361 B
SQL
15 lines
361 B
SQL
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM pg_constraint
|
|
WHERE conname = 'bills_source_invoice_id_fkey'
|
|
AND conrelid = 'public.bills'::regclass
|
|
) THEN
|
|
ALTER TABLE public.bills
|
|
ADD CONSTRAINT bills_source_invoice_id_fkey
|
|
FOREIGN KEY (source_invoice_id)
|
|
REFERENCES public.invoices(id)
|
|
ON DELETE SET NULL;
|
|
END IF;
|
|
END $$; |