Skip to content

Commit 923bb7a

Browse files
committed
migration files to update Attribute table values
1 parent 53a1f66 commit 923bb7a

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
2+
import { type JobDef } from '~db/prisma/jobPreRun'
3+
4+
/** Define the job metadata here. */
5+
const jobDef: JobDef = {
6+
jobId: '2025-03-05_update-attribute-values-asl',
7+
title: 'change the name values for ASL',
8+
createdBy: 'Diana Garbarino',
9+
/** Optional: Longer description for the job */
10+
description: 'change the name values for ASL',
11+
}
12+
/**
13+
* Job export - this variable MUST be UNIQUE
14+
*/
15+
export const job20250305_update_attribute_values_asl = {
16+
title: `[${jobDef.jobId}] ${jobDef.title}`,
17+
task: async (ctx, task) => {
18+
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
19+
/** Create logging instance */
20+
createLogger(task, jobDef.jobId)
21+
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
22+
23+
// Variables for the update
24+
const key = 'lang.american-sign-language'
25+
const ns = 'attribute'
26+
const newTextValue = 'American Sign Language (ASL)'
27+
// Perform the update
28+
const update1 = await prisma.translationKey.update({
29+
where: { ns_key: { key, ns } },
30+
data: { text: newTextValue },
31+
})
32+
33+
log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)
34+
35+
const update2 = await prisma.attribute.updateMany({
36+
where: { tsKey: key, tsNs: ns },
37+
data: { name: newTextValue },
38+
})
39+
40+
log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)
41+
42+
/**
43+
* DO NOT REMOVE BELOW
44+
*
45+
* This writes a record to the DB to register that this migration has run successfully.
46+
*/
47+
await jobPostRunner(jobDef)
48+
},
49+
def: jobDef,
50+
} satisfies MigrationJob
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
2+
import { type JobDef } from '~db/prisma/jobPreRun'
3+
4+
/** Define the job metadata here. */
5+
const jobDef: JobDef = {
6+
jobId: '2025-03-05_update-attribute-values-lang-inter',
7+
title: 'change the name values for All Languages',
8+
createdBy: 'Diana Garbarino',
9+
/** Optional: Longer description for the job */
10+
description: 'change the name values for All Languages',
11+
}
12+
/**
13+
* Job export - this variable MUST be UNIQUE
14+
*/
15+
export const job20250305_update_attribute_values_lang_inter = {
16+
title: `[${jobDef.jobId}] ${jobDef.title}`,
17+
task: async (ctx, task) => {
18+
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
19+
/** Create logging instance */
20+
createLogger(task, jobDef.jobId)
21+
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
22+
23+
// Variables for the update
24+
const key = 'lang.all-languages-by-interpreter'
25+
const ns = 'attribute'
26+
const newTextValue = 'Language assistance available. Contact for more information.'
27+
// Perform the update
28+
const update1 = await prisma.translationKey.update({
29+
where: { ns_key: { key, ns } },
30+
data: { text: newTextValue },
31+
})
32+
33+
log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)
34+
35+
const update2 = await prisma.attribute.updateMany({
36+
where: { tsKey: key, tsNs: ns },
37+
data: { name: newTextValue },
38+
})
39+
40+
log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)
41+
42+
/**
43+
* DO NOT REMOVE BELOW
44+
*
45+
* This writes a record to the DB to register that this migration has run successfully.
46+
*/
47+
await jobPostRunner(jobDef)
48+
},
49+
def: jobDef,
50+
} satisfies MigrationJob

packages/db/prisma/data-migrations/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ export * from './2025-02-17_new_mental-health-service-tag'
2626
export * from './2025-02-17_new-cost-attribute'
2727
export * from './2025-02-17_update-medical-tags'
2828
export * from './2025-03-01_update-locationbased-alert-string-add-emoji'
29+
export * from './2025-03-05_update-attribute-values-asl'
30+
export * from './2025-03-05_update-attribute-values-lang-inter'
2931
export * from './2025-03-05_update-nationwide-locationbased-alert'
3032
// codegen:end

0 commit comments

Comments
 (0)