Skip to content

Commit

Permalink
fix: differentiate baltimore city & county (#1299)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

# Pull Request type

<!-- Please try to limit your pull request to one type; submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Governing district dropdown lists "Baltimore" twice - one should be
"Baltimore City" and the other "Baltimore County"

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

-
-
-

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this does introduce a breaking change, please describe the
impact and migration path for existing applications below. -->

## Other information

<!-- Any other information that is important to this PR, such as
screenshots of how the component looks before and after the change. -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated location names in Maryland for better clarity, changing
"Baltimore" to "Baltimore City" and "Baltimore County".

- **Chores**
- Introduced a data migration job to update records related to Baltimore
City and Baltimore County in the database.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
JoeKarow authored Jun 14, 2024
1 parent c0ea459 commit 8b0f0d3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/app/public/locales/en/gov-dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,8 @@
"us-maryland": "Maryland",
"us-maryland-allegany-county": "Allegany",
"us-maryland-anne-arundel-county": "Anne Arundel",
"us-maryland-baltimore-city": "Baltimore",
"us-maryland-baltimore-county": "Baltimore",
"us-maryland-baltimore-city": "Baltimore City",
"us-maryland-baltimore-county": "Baltimore County",
"us-maryland-calvert-county": "Calvert",
"us-maryland-caroline-county": "Caroline",
"us-maryland-carroll-county": "Carroll",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2024-06-14_update-baltimore-to-reflect-city-and-county-options',
title: 'update baltimore to reflect city &amp; county options',
createdBy: 'Joe Karow',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20240614_update_baltimore_to_reflect_city_and_county_options = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, downloadFromDatastore, generateId, formatMessage, jobPostRunner, prisma } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
/**
* Start defining your data migration from here.
*
* To log output, use `task.output = 'Message to log'`
*
* This will be written to `stdout` and to a log file in `/prisma/migration-logs/`
*/

// Do stuff

const update = await prisma.$transaction([
prisma.govDist.update({
where: { slug: 'us-maryland-baltimore-county' },
data: {
name: 'Baltimore County',
key: { update: { text: 'Baltimore County' } },
},
}),
prisma.govDist.update({
where: { slug: 'us-maryland-baltimore-city' },
data: {
name: 'Baltimore City',
key: { update: { text: 'Baltimore City' } },
},
}),
])
log(`govDist records updated: ${update.length}`)

/**
* DO NOT REMOVE BELOW
*
* This writes a record to the DB to register that this migration has run successfully.
*/
await jobPostRunner(jobDef)
},
def: jobDef,
} satisfies MigrationJob
1 change: 1 addition & 0 deletions packages/db/prisma/data-migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export * from './2024-03-21_attribute-supplement-schemas'
export * from './2024-04-03_access-instruction-schemas'
export * from './2024-04-24_update-crowdin-ids'
export * from './2024-04-25_translation-activation-flag'
export * from './2024-06-14_update-baltimore-to-reflect-city-and-county-options'
// codegen:end

0 comments on commit 8b0f0d3

Please sign in to comment.