mirror of
https://github.com/OHTU-German-learning-website/OHTU-German-learning-website.git
synced 2026-10-12 19:13:51 +03:00
16 lines
377 B
SQL
16 lines
377 B
SQL
ALTER TABLE glossary_entries
|
|
ADD COLUMN IF NOT EXISTS updated_by bigint;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM pg_constraint
|
|
WHERE conname = 'glossary_entries_updated_by_fkey'
|
|
) THEN
|
|
ALTER TABLE glossary_entries
|
|
ADD CONSTRAINT glossary_entries_updated_by_fkey
|
|
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL;
|
|
END IF;
|
|
END $$;
|