1
Fork 0

database: Allow meta_subjects.subject to be null

This commit is contained in:
Steffo 2024-11-18 18:24:15 +01:00
parent 17a0dfd21d
commit 1322023e23
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,10 @@
UPDATE meta_subjects SET subject = 'invalid:subject.null' WHERE subject IS NULL;
ALTER TABLE meta_subjects ALTER subject SET NOT NULL;
ALTER TABLE meta_subjects ADD CONSTRAINT either_subject_or_redirect_not_null
CHECK (
(subject IS NOT NULL AND redirect IS NULL)
OR
(subject IS NULL AND redirect IS NOT NULL)
);

View file

@ -0,0 +1,5 @@
ALTER TABLE meta_subjects DROP CONSTRAINT either_subject_or_redirect_not_null;
ALTER TABLE meta_subjects ALTER subject DROP NOT NULL;
UPDATE meta_subjects SET subject = NULL WHERE subject = 'invalid:subject.null';