Skip to content

Commit

Permalink
feat(db): updated migration script for location based alert url link (#…
Browse files Browse the repository at this point in the history
…1443)

<!--- 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:

- [ ] Bugfix
- [x] 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?

the current link for erin in the morning is outdated

Issue Number: N/A

## What is the new behavior?
this migration script updates that link

-
-
-

## 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. -->
  • Loading branch information
trigal2012 authored Jan 11, 2025
2 parents c56f243 + eb2cf8c commit 83993ac
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-01-07_update-locationbased-alert-string',
title: 'change the erin in the morning alert link',
createdBy: 'Diana',
/** Optional: Longer description for the job */
description: 'change the erin in the morning alert link',
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250107_update_locationbased_alert_string = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))

// Variables for the update
const key = 'locationBasedAlert.alrt_01J1D1GAT5G5S6QNMCND5PMDAX'
const ns = 'org-data'
const newTextValue =
'This <Link href="https://www.erininthemorning.com/p/post-election-2024-anti-trans-risk">anti-trans legislative risk map</Link> shows the 2-year risk for anti-trans laws in all 50 states and D.C.'

// Perform the update
const update = await prisma.translationKey.update({
where: { ns_key: { key, ns } },
data: { text: newTextValue },
})

log(`Location-based alert text string updated: ${update.key} with new text: "${update.text}"`)

/**
* 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 @@ -11,4 +11,5 @@ export * from './2024-07-29_address-visibility-update'
export * from './2024-07-29_new-service-tags'
export * from './2024-08-22_election-alert'
export * from './2024-12-22_update-alert-link'
export * from './2025-01-07_update-locationbased-alert-string'
// codegen:end

0 comments on commit 83993ac

Please sign in to comment.