Skip to content

Commit

Permalink
update cost attributes to active
Browse files Browse the repository at this point in the history
  • Loading branch information
trigal2012 committed Jan 16, 2025
1 parent 49f34bb commit 88843d1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/db/prisma/data-migrations/2025-01-15_update-cost-tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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-15_update-cost-tags-to-active',
title: 'update cost tags to active',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250115_update_cost_tags_to_active = {
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.attribute.update({
where: { tsKey_tsNs: { tsKey: 'cost.cost-sliding-scale', tsNs: 'attribute' } },
data: {
active: true,
},
}),
prisma.attribute.update({
where: { tsKey_tsNs: { tsKey: 'cost.cost-accepts-insurance', tsNs: 'attribute' } },
data: {
active: true,
},
}),
])
log(`attribute 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
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 @@ -13,5 +13,6 @@ export * from './2024-08-22_election-alert'
export * from './2024-12-22_update-alert-link'
export * from './2025-01-07_update-locationbased-alert-string'
export * from './2025-01-15_new_food-service-tag'
export * from './2025-01-15_update-cost-tags'
export * from './2025-01-15_update-food-tags'
// codegen:end

0 comments on commit 88843d1

Please sign in to comment.