-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add character_type_implies_no_end DB constraint
Characters should never have an end date or area; this just enforces it at the database level like we do with group genders.
- Loading branch information
1 parent
3cb0b5d
commit 48f9385
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
\set ON_ERROR_STOP 1 | ||
|
||
BEGIN; | ||
|
||
UPDATE artist | ||
SET end_date_day = NULL, | ||
end_date_month = NULL, | ||
end_date_year = NULL, | ||
end_area = NULL, | ||
ended = FALSE | ||
WHERE type = 4; | ||
|
||
ALTER TABLE artist | ||
DROP CONSTRAINT IF EXISTS character_type_implies_no_end; | ||
|
||
ALTER TABLE artist | ||
ADD CONSTRAINT character_type_implies_no_end CHECK ( | ||
( | ||
type = 4 AND | ||
end_date_day IS NULL AND | ||
end_date_month IS NULL AND | ||
end_date_year IS NULL AND | ||
end_area IS NULL AND | ||
ended = FALSE | ||
) | ||
OR type != 4 | ||
); | ||
|
||
COMMIT; |
35 changes: 35 additions & 0 deletions
35
admin/sql/updates/schema-change/30.master_and_standalone.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Generated by CompileSchemaScripts.pl from: | ||
-- 20241104-mbs-9885.sql | ||
\set ON_ERROR_STOP 1 | ||
BEGIN; | ||
SET search_path = musicbrainz, public; | ||
SET LOCAL statement_timeout = 0; | ||
-------------------------------------------------------------------------------- | ||
SELECT '20241104-mbs-9885.sql'; | ||
|
||
|
||
UPDATE artist | ||
SET end_date_day = NULL, | ||
end_date_month = NULL, | ||
end_date_year = NULL, | ||
end_area = NULL, | ||
ended = FALSE | ||
WHERE type = 4; | ||
|
||
ALTER TABLE artist | ||
DROP CONSTRAINT IF EXISTS character_type_implies_no_end; | ||
|
||
ALTER TABLE artist | ||
ADD CONSTRAINT character_type_implies_no_end CHECK ( | ||
( | ||
type = 4 AND | ||
end_date_day IS NULL AND | ||
end_date_month IS NULL AND | ||
end_date_year IS NULL AND | ||
end_area IS NULL AND | ||
ended = FALSE | ||
) | ||
OR type != 4 | ||
); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters