From 5be671eb4cf47bb75783b52a42cd679126222a62 Mon Sep 17 00:00:00 2001 From: DMAC1 Date: Sun, 22 Dec 2024 22:24:39 -0800 Subject: [PATCH 1/6] Update anti-trans risk map link (search results banner alert) --- .../db/prisma/data-migrations/2024-12-22_update-alert-link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts index 5d9b856155..b1f6750588 100644 --- a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts +++ b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts @@ -46,7 +46,7 @@ export const job20241222_update_alert_link = { type: 'locationAlert', freeTextId: existingAlert.text.freeTextId, // Retain the same freeTextId to avoid changing other content itemId: alertId, - text: 'This new anti-trans legislative risk map shows updated risk information.', + text: 'This new anti-trans legislative risk map shows updated risk information.', }), }, }) From 5522d78c9efb9e481016196b1c5cebe65e642de3 Mon Sep 17 00:00:00 2001 From: DMAC1 Date: Mon, 23 Dec 2024 12:51:30 -0800 Subject: [PATCH 2/6] Update anti-trans risk map link (search results banner alert), attempt 2 --- .../db/prisma/data-migrations/2024-12-22_update-alert-link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts index b1f6750588..588f797c5e 100644 --- a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts +++ b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts @@ -46,7 +46,7 @@ export const job20241222_update_alert_link = { type: 'locationAlert', freeTextId: existingAlert.text.freeTextId, // Retain the same freeTextId to avoid changing other content itemId: alertId, - text: 'This new anti-trans legislative risk map shows updated risk information.', + text: 'This anti-trans legislative risk map shows the 2-year risk for anti-trans laws in all 50 states and D.C.', }), }, }) From 772c322bd4c378030396b8caa0c4c2d261f0b0f1 Mon Sep 17 00:00:00 2001 From: DMAC1 Date: Mon, 23 Dec 2024 12:59:30 -0800 Subject: [PATCH 3/6] Update anti-trans risk map link (search results banner alert), attempt 3 --- .../2024-12-22_update-alert-link.ts | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts index 588f797c5e..1b681115c9 100644 --- a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts +++ b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts @@ -1,57 +1,51 @@ import { generateNestedFreeText } from '~db/lib/generateFreeText' import { type MigrationJob } from '~db/prisma/dataMigrationRunner' import { type JobDef } from '~db/prisma/jobPreRun' - /** Define the job metadata here. */ const jobDef: JobDef = { - jobId: '2024-12-22_update-alert-link', - title: 'Update alert link', - createdBy: 'Diana Garbarino', + jobId: '2024-06-27_search-page-alert', + title: 'Search page alert', + createdBy: 'Joe Karow', /** Optional: Longer description for the job */ - description: 'This migration script updates the alert text with a new link.', + description: undefined, } - /** * Job export - this variable MUST be UNIQUE */ -export const job20241222_update_alert_link = { +export const job202401222_update_alert_link = { title: `[${jobDef.jobId}] ${jobDef.title}`, task: async (ctx, task) => { - const { createLogger, jobPostRunner, prisma, formatMessage } = ctx + const { createLogger, downloadFromDatastore, generateId, formatMessage, jobPostRunner, prisma } = ctx /** Create logging instance */ createLogger(task, jobDef.jobId) const log = (...args: Parameters) => (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/` + */ - // Log that the script has started - log('Starting to update the alert link.') + // Do stuff - // Define the alertId you wish to update const alertId = 'alrt_01J1D1GAT5G5S6QNMCND5PMDAX' - // Fetch the existing alert record - const existingAlert = await prisma.locationAlert.findUnique({ - where: { id: alertId }, - }) - - if (!existingAlert) { - log(`Alert with ID ${alertId} not found.`) - return - } - - // Update the 'text' field with a new link - const updatedAlert = await prisma.locationAlert.update({ - where: { id: alertId }, + const newAlert = await prisma.locationAlert.create({ data: { + id: alertId, + level: 'WARN_PRIMARY', text: generateNestedFreeText({ type: 'locationAlert', - freeTextId: existingAlert.text.freeTextId, // Retain the same freeTextId to avoid changing other content + freeTextId: 'ftxt_01J1D1GVD7X1VBKZMPJ8AKYYMB', itemId: alertId, - text: 'This anti-trans legislative risk map shows the 2-year risk for anti-trans laws in all 50 states and D.C.', + text: 'This anti-trans legislative risk map shows the 2-year risk for anti-trans laws in all 50 states and D.C.', }), + country: { connect: { cca2: 'US' } }, }, }) - log(`Updated alert ${updatedAlert.id} with new link`) + log(`Created alert ${newAlert.id}`) /** * DO NOT REMOVE BELOW From 01e087116971944ce80be00abd3e47e0e2fbb2a0 Mon Sep 17 00:00:00 2001 From: DMAC1 Date: Mon, 23 Dec 2024 13:03:24 -0800 Subject: [PATCH 4/6] Update anti-trans risk map link (search results banner alert), attempt 4 --- .../prisma/data-migrations/2024-12-22_update-alert-link.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts index 1b681115c9..85606b9bca 100644 --- a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts +++ b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts @@ -3,16 +3,16 @@ import { type MigrationJob } from '~db/prisma/dataMigrationRunner' import { type JobDef } from '~db/prisma/jobPreRun' /** Define the job metadata here. */ const jobDef: JobDef = { - jobId: '2024-06-27_search-page-alert', + jobId: '2024-12-22_update-alert-link', title: 'Search page alert', - createdBy: 'Joe Karow', + createdBy: 'Diana Garbarino', /** Optional: Longer description for the job */ description: undefined, } /** * Job export - this variable MUST be UNIQUE */ -export const job202401222_update_alert_link = { +export const job20240627_search_page_alert = { title: `[${jobDef.jobId}] ${jobDef.title}`, task: async (ctx, task) => { const { createLogger, downloadFromDatastore, generateId, formatMessage, jobPostRunner, prisma } = ctx From 0097dc2aab8ad0dd9b1b23ccc8086fd15dd8d63d Mon Sep 17 00:00:00 2001 From: "InReach [bot]" <108850934+InReach-svc@users.noreply.github.com> Date: Mon, 23 Dec 2024 21:09:27 +0000 Subject: [PATCH 5/6] chore: lint & format Signed-off-by: InReach [bot] <108850934+InReach-svc@users.noreply.github.com> --- packages/db/prisma/data-migrations/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/db/prisma/data-migrations/index.ts b/packages/db/prisma/data-migrations/index.ts index 14a85dd76b..82e1512ccd 100644 --- a/packages/db/prisma/data-migrations/index.ts +++ b/packages/db/prisma/data-migrations/index.ts @@ -10,4 +10,5 @@ export * from './2024-06-28_new-cost-props' export * from './2024-07-29_address-visibility-update' export * from './2024-07-29_new-service-tags' export * from './2024-08-22_election-alert' +export * from './2024-12-22_update-alert-link' // codegen:end From 7c23e69f5dbe2eb858e01288cee84afb27ef9633 Mon Sep 17 00:00:00 2001 From: DMAC1 Date: Mon, 23 Dec 2024 13:16:01 -0800 Subject: [PATCH 6/6] Update anti-trans risk map link (search results banner alert), attempt 5 --- .../db/prisma/data-migrations/2024-12-22_update-alert-link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts index 85606b9bca..ec9ef65b2f 100644 --- a/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts +++ b/packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts @@ -12,7 +12,7 @@ const jobDef: JobDef = { /** * Job export - this variable MUST be UNIQUE */ -export const job20240627_search_page_alert = { +export const job20241222_update_alert_link = { title: `[${jobDef.jobId}] ${jobDef.title}`, task: async (ctx, task) => { const { createLogger, downloadFromDatastore, generateId, formatMessage, jobPostRunner, prisma } = ctx