forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: region and variable naming update #1304
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b3187c2
fix: region and variable naming update
ColinBuyck 7bfde53
fix: updated related tests
ColinBuyck 522d1ef
fix: mantain full set of neighborhoods
ColinBuyck d61336e
Merge branch 'dev' into 1296/region-update
ColinBuyck acce66a
Merge branch 'dev' into 1296/region-update
ColinBuyck ed39723
fix: new migration file
ColinBuyck 708ef37
fix: migration for existing Downtown data
ColinBuyck a1932ac
Merge branch 'dev' into 1296/region-update
ColinBuyck aa604d1
fix: remove region typing from seed
ColinBuyck 06d872b
fix: update script to pass unit tests
ColinBuyck 6efa15e
fix: contain all migration fixes to new file
ColinBuyck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class regionRename1654549186207 implements MigrationInterface { | ||
name = "regionRename1654549186207" | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`BEGIN TRANSACTION`) | ||
await queryRunner.query(`ALTER TYPE "property_region_enum" ADD VALUE 'Greater Downtown'`) | ||
await queryRunner.query(`COMMIT TRANSACTION`) | ||
await queryRunner.query( | ||
`UPDATE "property" SET "region" = 'Greater Downtown' WHERE "region" = 'Downtown'` | ||
) | ||
await queryRunner.query( | ||
`ALTER TYPE "property_region_enum" RENAME TO "property_region_enum_old"` | ||
) | ||
await queryRunner.query( | ||
`CREATE TYPE "property_region_enum" AS ENUM('Greater Downtown', 'Eastside', 'Southwest', 'Westside')` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "property" ALTER COLUMN "region" TYPE "property_region_enum" USING "region"::"text"::"property_region_enum"` | ||
) | ||
await queryRunner.query(`DROP TYPE "property_region_enum_old"`) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TYPE "property_region_enum_old" AS ENUM('Greater Downtown', 'Eastside', 'Midtown - New Center', 'Southwest', 'Westside')` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "property" ALTER COLUMN "region" TYPE "property_region_enum_old" USING "region"::"text"::"property_region_enum_old"` | ||
) | ||
await queryRunner.query(`DROP TYPE "property_region_enum"`) | ||
await queryRunner.query( | ||
`ALTER TYPE "property_region_enum_old" RENAME TO "property_region_enum"` | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export enum Region { | ||
Downtown = "Downtown", | ||
GreaterDowntown = "Greater Downtown", | ||
Eastside = "Eastside", | ||
MidtownNewCenter = "Midtown - New Center", | ||
Southwest = "Southwest", | ||
Westside = "Westside", | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making an update to an existing migration is a flow we can't use. It will work locally on a
db:reseed
because this runs every single migration from the first, but once this gets to dev/production where we have an existing db, all the migration files are not run, just any new ones. You can test this locally by reseeding on dev, and then on this branch just runningyarn db:migration:run
to test what would happen in our environments. I'd suggest keeping the update to theregion-enum
and then runningyarn db:migration:generate -n 'region-rename'
and the backend will auto-generate a new migration file for you based on whatever changes were made. Sometimes doing this results in some extra db queries we don't always need, so some things may need to be removed other than altering the enum.