Skip to content

Commit

Permalink
Feature: updated translationKet text value as well(ECB-91) (#1456)
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:

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

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

Issue Number: N/A

## What is the new behavior?
needed to update the translation key table as well

-
-
-

## 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 29, 2025
2 parents f8a779e + 5e94d46 commit 07b78c2
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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-29_update-translation-key-for-trans-health-youth',
title: 'update translation key for trans health youth',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250129_update_translation_key_for_trans_health_youth = {
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/`
*/

// Find the translation key using `ns_key`
const translationKey = await prisma.translationKey.findUnique({
where: {
ns_key: {
ns: 'services', // Namespace set as 'services'
key: 'medical.trans-health-youth-care', // The key to update
},
},
})

if (!translationKey) {
throw new Error('Translation key not found.')
}

console.log('Found Translation Key:', translationKey)

// Update the translation key's text field
const updatedTranslationKey = await prisma.translationKey.update({
where: {
ns_key: {
ns: 'services',
key: 'medical.trans-health-youth-care',
},
},
data: {
text: 'Trans - youth care', // The updated text value
},
})

console.log('Updated Translation Key:', updatedTranslationKey)

/**
* 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 @@ -17,4 +17,5 @@ export * from './2025-01-15_new_medical-service-tag'
export * from './2025-01-15_update-cost-tags'
export * from './2025-01-15_update-food-tags'
export * from './2025-01-29_update-parent-category-for-trans-you-health'
export * from './2025-01-29_update-translation-key-for-trans-health-youth'
// codegen:end

0 comments on commit 07b78c2

Please sign in to comment.