From 228c73a0e690e3d6a013218617c24a48b4e54d0f Mon Sep 17 00:00:00 2001 From: trigal Date: Wed, 29 Jan 2025 17:13:01 -0800 Subject: [PATCH] add alert for trans bans org changes --- ...9_update-nationwide-locationbased-alert.ts | 51 +++++++++++++++++++ packages/db/prisma/data-migrations/index.ts | 1 + 2 files changed, 52 insertions(+) create mode 100644 packages/db/prisma/data-migrations/2025-01-29_update-nationwide-locationbased-alert.ts diff --git a/packages/db/prisma/data-migrations/2025-01-29_update-nationwide-locationbased-alert.ts b/packages/db/prisma/data-migrations/2025-01-29_update-nationwide-locationbased-alert.ts new file mode 100644 index 0000000000..672129f442 --- /dev/null +++ b/packages/db/prisma/data-migrations/2025-01-29_update-nationwide-locationbased-alert.ts @@ -0,0 +1,51 @@ +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-nationwide-locationbased-alert', + title: 'change the location-based alert text string', + createdBy: 'Diana', + /** Optional: Longer description for the job */ + description: 'change the location-based alert text string', +} +/** + * Job export - this variable MUST be UNIQUE + */ +export const job20250129_update_nationwide_locationbased_alert = { + 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) => (task.output = formatMessage(...args)) + + // Variables for the update + const key = 'locationBasedAlert.alrt_locationBasedAlert.alrt_01J5XNBQ5GREHSHK5D2QTCXRWE' + const ns = 'org-data' + const newTextValue = + 'Some organizations are adjusting services due to recent funding cuts and policy changes. Contact providers directly for updates.' + + // Perform the update + const update1 = await prisma.translationKey.update({ + where: { ns_key: { key, ns } }, + data: { text: newTextValue }, + }) + + const update2 = await prisma.locationAlert.update({ + where: { id: 'alrt_01J1D1GAT5G5S6QNMCND5PMDAX' }, + data: { level: 'WARN_SECONDARY' }, // update this to the correct id + }) + + log(`Location-based alert text string updated: ${update1.key} with new text: "${update1.text}"`) + log(`Location-based alert level type for anti-trans map: ${update2.key} change to: "${update2.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 diff --git a/packages/db/prisma/data-migrations/index.ts b/packages/db/prisma/data-migrations/index.ts index c28b548e38..f2a8bb10d0 100644 --- a/packages/db/prisma/data-migrations/index.ts +++ b/packages/db/prisma/data-migrations/index.ts @@ -16,6 +16,7 @@ export * from './2025-01-15_new_food-service-tag' 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-nationwide-locationbased-alert' 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