generated from MapColonies/ts-server-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db): make
percentage
column NOT NULL and add DEFAULT 0 (#50)
* feat(db): make `percentage` column NOT NULL and add DEFAULT 0 BREAKING CHANGE: - The `percentage` column is now NOT NULL. This will cause failures in any code attempting to insert or update rows with a null value for `percentage`. - Existing data has been migrated to set null values to 0. - A DEFAULT constraint of 0 has been added, altering the behavior of inserts when `percentage` is not specified. Applications relying on nullable `percentage` values or handling null explicitly must be updated to comply with these changes. * chore(db):migration script version change
- Loading branch information
Showing
4 changed files
with
28 additions
and
4 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
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,24 @@ | ||
SET search_path TO "JobManager", public; -- CHANGE SCHEMA NAME TO MATCH ENVIRONMENT | ||
|
||
-- Update existing null values to 0 in Job table | ||
UPDATE "Job" | ||
SET "percentage" = 0 | ||
WHERE "percentage" IS NULL; | ||
|
||
-- Update existing null values to 0 in Task table | ||
UPDATE "Task" | ||
SET "percentage" = 0 | ||
WHERE "percentage" IS NULL; | ||
|
||
-- Modify Job table column | ||
ALTER TABLE "Job" | ||
ALTER COLUMN "percentage" SET DEFAULT 0, | ||
ALTER COLUMN "percentage" SET NOT NULL; | ||
|
||
-- Modify Task table column | ||
ALTER TABLE "Task" | ||
ALTER COLUMN "percentage" SET DEFAULT 0, | ||
ALTER COLUMN "percentage" SET NOT NULL; | ||
|
||
COMMENT ON COLUMN "Job"."percentage" IS 'Percentage of job completion (0-100). Default is 0.'; | ||
COMMENT ON COLUMN "Task"."percentage" IS 'Percentage of task completion (0-100). Default is 0.'; |