-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Adjust "Trans health - youth care" tag to respond to policy …
…changes (ECB-91) (#1455) <!--- 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? (1) Update our "Trans health - youth care" tag to be more vague; new tag name = "Trans youth support" (2) Move new renamed tag from showing under “Medical” category and just list under the “Mental Health” category (& cross-list under the “Trans Focused Services” category) on the live front-end and in the data portal. - - - ## 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
Showing
3 changed files
with
95 additions
and
1 deletion.
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
93 changes: 93 additions & 0 deletions
93
packages/db/prisma/data-migrations/2025-01-29_update-parent-category-for-trans-you-health.ts
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 @@ | ||
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-parent-category-for-trans-you-health', | ||
title: 'update parent category for trans you health', | ||
createdBy: 'Diana Garbarino', | ||
/** Optional: Longer description for the job */ | ||
description: undefined, | ||
} | ||
/** | ||
* Job export - this variable MUST be UNIQUE | ||
*/ | ||
export const job20250129_update_parent_category_for_trans_you_health = { | ||
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.serviceTag.update({ | ||
where: { id: 'svtg_01HAD647BVMT10DWEXFG1EFM9J' }, | ||
data: { name: 'Trans - youth care' }, | ||
}), | ||
]) | ||
|
||
// Extract the serviceTagId from the update result | ||
const serviceTagId = update[0].id | ||
console.log('Updated ServiceTag ID:', serviceTagId) | ||
|
||
// Find the category IDs for "Medical" and "Mental Health" | ||
const categories = await prisma.serviceCategory.findMany({ | ||
where: { | ||
category: { | ||
in: ['Medical', 'Mental Health'], | ||
}, | ||
}, | ||
select: { id: true, category: true }, | ||
}) | ||
|
||
// Extract the IDs for "Medical" and "Mental Health" | ||
const medicalCategory = categories.find((c) => c.category === 'Medical') | ||
const mentalHealthCategory = categories.find((c) => c.category === 'Mental Health') | ||
|
||
if (!medicalCategory || !mentalHealthCategory) { | ||
throw new Error("Could not find category IDs for 'Medical' or 'Mental Health'") | ||
} | ||
|
||
console.log('Medical Category ID:', medicalCategory.id) | ||
console.log('Mental Health Category ID:', mentalHealthCategory.id) | ||
|
||
// Update ServiceTagToCategory where categoryId = Medical and serviceTagId = updated serviceTagId | ||
const updateResult = await prisma.$transaction([ | ||
prisma.serviceTagToCategory.updateMany({ | ||
where: { | ||
categoryId: medicalCategory.id, | ||
serviceTagId: serviceTagId, | ||
}, | ||
data: { | ||
categoryId: mentalHealthCategory.id, // Change to Mental Health's ID | ||
}, | ||
}), | ||
]) | ||
|
||
console.log('Updated ServiceTagToCategory rows:', updateResult) | ||
console.log('Category ID changed from', medicalCategory.id, 'to', mentalHealthCategory.id) | ||
console.log('For ServiceTag ID:', serviceTagId) | ||
|
||
console.log('Update complete!') | ||
|
||
log(`serviceTag 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 |
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