-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trims fname/lname on save and dob -> numbers (#4027)
* fix: trims fname/lname on save and dob -> numbers * trim existing data * fix: now saving household member data correctly * fix: migration to remove spaces from rulekeys * fix: updates to migration * fix: var update per eric
- Loading branch information
1 parent
76d1075
commit 42b26e0
Showing
13 changed files
with
270 additions
and
162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
converts `birth_month`, `birth_day`, `birth_year` columns from strings to integers for the "applicant" and "household_member" tables | ||
*/ | ||
|
||
-- AlterTable applicant | ||
ALTER TABLE "applicant" ADD COLUMN "birth_year_temp" INTEGER; | ||
ALTER TABLE "applicant" ADD COLUMN "birth_month_temp" INTEGER; | ||
ALTER TABLE "applicant" ADD COLUMN "birth_day_temp" INTEGER; | ||
|
||
UPDATE "applicant" SET | ||
"birth_year_temp" = CASE WHEN "birth_year" = NULL THEN NULL ELSE "birth_year" :: Integer END, | ||
"birth_month_temp" = CASE WHEN "birth_month" = NULL THEN NULL ELSE "birth_month" :: Integer END, | ||
"birth_day_temp" = CASE WHEN "birth_day" = NULL THEN NULL ELSE "birth_day" :: Integer END; | ||
|
||
ALTER TABLE "applicant" DROP COLUMN "birth_year"; | ||
ALTER TABLE "applicant" DROP COLUMN "birth_month"; | ||
ALTER TABLE "applicant" DROP COLUMN "birth_day"; | ||
|
||
ALTER TABLE "applicant" ADD COLUMN "birth_year" INTEGER; | ||
ALTER TABLE "applicant" ADD COLUMN "birth_month" INTEGER; | ||
ALTER TABLE "applicant" ADD COLUMN "birth_day" INTEGER; | ||
|
||
UPDATE "applicant" SET | ||
"birth_year" = "birth_year_temp", | ||
"birth_month" = "birth_month_temp", | ||
"birth_day" = "birth_day_temp", | ||
"first_name" = TRIM("first_name"), | ||
"last_name" = TRIM("last_name"); | ||
|
||
ALTER TABLE "applicant" DROP COLUMN "birth_year_temp"; | ||
ALTER TABLE "applicant" DROP COLUMN "birth_month_temp"; | ||
ALTER TABLE "applicant" DROP COLUMN "birth_day_temp"; | ||
|
||
-- AlterTable household_member | ||
ALTER TABLE "household_member" ADD COLUMN "birth_year_temp" INTEGER; | ||
ALTER TABLE "household_member" ADD COLUMN "birth_month_temp" INTEGER; | ||
ALTER TABLE "household_member" ADD COLUMN "birth_day_temp" INTEGER; | ||
|
||
UPDATE "household_member" SET | ||
"birth_year_temp" = CASE WHEN "birth_year" = NULL THEN NULL ELSE "birth_year" :: Integer END, | ||
"birth_month_temp" = CASE WHEN "birth_month" = NULL THEN NULL ELSE "birth_month" :: Integer END, | ||
"birth_day_temp" = CASE WHEN "birth_day" = NULL THEN NULL ELSE "birth_day" :: Integer END; | ||
|
||
ALTER TABLE "household_member" DROP COLUMN "birth_year"; | ||
ALTER TABLE "household_member" DROP COLUMN "birth_month"; | ||
ALTER TABLE "household_member" DROP COLUMN "birth_day"; | ||
|
||
ALTER TABLE "household_member" ADD COLUMN "birth_year" INTEGER; | ||
ALTER TABLE "household_member" ADD COLUMN "birth_month" INTEGER; | ||
ALTER TABLE "household_member" ADD COLUMN "birth_day" INTEGER; | ||
|
||
UPDATE "household_member" SET | ||
"birth_year" = "birth_year_temp", | ||
"birth_month" = "birth_month_temp", | ||
"birth_day" = "birth_day_temp", | ||
"first_name" = TRIM("first_name"), | ||
"last_name" = TRIM("last_name"); | ||
|
||
ALTER TABLE "household_member" DROP COLUMN "birth_year_temp"; | ||
ALTER TABLE "household_member" DROP COLUMN "birth_month_temp"; | ||
ALTER TABLE "household_member" DROP COLUMN "birth_day_temp"; | ||
|
||
|
||
-- Unify AFS | ||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, ' ', ''); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-01-', '-1-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-02-', '-2-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-03-', '-3-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-04-', '-4-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-05-', '-5-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-06-', '-6-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-07-', '-7-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-08-', '-8-'); | ||
|
||
UPDATE application_flagged_set | ||
SET rule_key = REPLACE(rule_key, '-09-', '-9-'); |
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
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
Oops, something went wrong.