diff --git a/packages/db/prisma/data-migrations/2023-09-22_service-areas.ts b/packages/db/prisma/data-migrations/2023-09-22_service-areas.ts new file mode 100644 index 00000000000..53dc582e6f3 --- /dev/null +++ b/packages/db/prisma/data-migrations/2023-09-22_service-areas.ts @@ -0,0 +1,87 @@ +import { prisma } from '~db/client' +import { formatMessage } from '~db/prisma/common' +import { type MigrationJob } from '~db/prisma/dataMigrationRunner' +import { createLogger, type JobDef, jobPostRunner } from '~db/prisma/jobPreRun' + +/** Define the job metadata here. */ +const jobDef: JobDef = { + jobId: '2023-09-22-service-areas', + title: 'service areas', + createdBy: 'Joe Karow', + /** Optional: Longer description for the job */ + description: undefined, +} +/** Job export - this variable MUST be UNIQUE */ +export const job20230922_service_areas = { + title: `[${jobDef.jobId}] ${jobDef.title}`, + task: async (_ctx, task) => { + /** 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/` + */ + + // Do stuff + const countryId = 'ctry_01GW2HHDK9M26M80SG63T21SVH' + const serviceAreaC = await prisma.serviceAreaCountry.createMany({ + data: [ + { + serviceAreaId: 'svar_01H56ESE0Y8CXJAA9N9DAZ295R', + countryId, + }, + { + serviceAreaId: 'svar_01H29ENFH36S5EDJ5TXV3RCDZF', + countryId, + }, + { + serviceAreaId: 'svar_01H29ENFGZACTZTZY2S4HDVQ5N', + countryId, + }, + { + serviceAreaId: 'svar_01H56ESDYKHW5W5EK02XJ4RFZH', + countryId, + }, + ], + skipDuplicates: true, + }) + log(`Service areas updated: ${serviceAreaC.count}`) + + const orgLocationServ = await prisma.orgLocationService.createMany({ + data: [ + { + orgLocationId: 'oloc_01H299KDJ5158R5JW6TY02Q9S3', + serviceId: 'osvc_01H299KDJ9TCMS7WWZVQYBBK9Z', + active: true, + }, + { + orgLocationId: 'oloc_01H299KEERBMZVAJPN5WZJN32E', + serviceId: 'osvc_01H299KEES84DAC2VA0XVH935H', + }, + ], + skipDuplicates: true, + }) + log(`Location/Service links: ${orgLocationServ.count}`) + + const orgLocationUpdates = await prisma.orgLocation.updateMany({ + where: { id: { in: ['oloc_01H299KDJ5158R5JW6TY02Q9S3', 'oloc_01H299KEERBMZVAJPN5WZJN32E'] } }, + data: { + mailOnly: true, + notVisitable: true, + published: true, + }, + }) + log(`Locations updated: ${orgLocationUpdates.count}`) + /** + * 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/2023-09-22_update-alerts/data.json b/packages/db/prisma/data-migrations/2023-09-22_update-alerts/data.json new file mode 100644 index 00000000000..9265df547e6 --- /dev/null +++ b/packages/db/prisma/data-migrations/2023-09-22_update-alerts/data.json @@ -0,0 +1 @@ +{"deactivate":[{"organizationId":"orgn_01GVH3V51EH3SMAYF72Z00WBEA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4QJZ6GBA5PQM13NCDSD","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8TWPT23MCXC3WTSJBQH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V93YHPMBKCY1T54X9XHM","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V775887661AW4BCN6H3K","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V94VBEYSJMYB79FWQ38G","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V61FAZQGQ1ZDGBXVD79V","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7JPFXQ5FP82SNPN2GJ7","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V45NRVSEDP6ZZSPG3NQK","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6CHMS0RZWF1M1AP66P3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V63DKK4NPHMMVQSD56Q6","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7QYZXNQCNPGYS6W8SQ1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVXXKRQDZAH7CWZNMAC73QAW","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5RY4X57F52TTEWF11M6","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8XM1NTT95XBWCG17MVH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V40YA1CHT0NP166WBBHV","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7C47X42VEC2KBHPWEJX","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4SGKMGMNBEM4ZQXK5HV","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4XAJ5Z7J4QT1BJW3JZT","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7RW200PSQDY9T56HDNW","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V79FB72N5FC40BCN2XFN","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V42X7G4S7HEDTFZVBDDA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7S0S5GTR3JJMCMT521R","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V3XS157NRPE4R795FMBG","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VAA0DMQFAYJRCFS5BKTY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6MZ2SCKX073EWGNC626","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V63NDSDRZCMYZ5W0Z776","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5BEWQ3XFQ0HD6MK65JD","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V62530YM26Y4EGVGK70R","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5F66T0JT27F4ZKYDPDT","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VAY56YN83HFTNMZVB5F9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6MWZCZ2BEN6C3RK1MAA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VBB12BFN8QA62E1EJGTY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VB7XW1HZ4ZZ0XB0GQQ5J","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4HJF8YRAYNNE55Q7TQX","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6Q9DCWGHG3FCVBPCF1E","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6JQHK51ZM9NNM3T0XW3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V56N3R0WFAGBCXA412DQ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6547ZAX72YEJH7T154Q","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4F34AHYM614N2EYY7M2","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4MT8QBB7JSP7HSYAZ7Y","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6EXFJ0VVZQG57XV1E0N","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4CVWH42SN15J52NC8TE","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V59V3MFMZ59QC5YRMXAJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V3XHSA7076QYDAFXE43C","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6937YQ5PAEP2GD2SCV3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5RT7CR1RMSEJJ7QK73K","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7CRNE591HY6FPSWV8C9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7KH1ZE9TH32P95CS4DF","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V90HJ9RK6799WNZMY86S","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6YSX82YS1HA1981X0WY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA6YXJKS5GTSYKBYGKS5","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V43VTXXF9FET8M5J2GNA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6RXCY6WZPM44SX7HQN4","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01H29CX1WNNKBRNQA4GZ289WWP","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5FSW2ZJN5B2WBF071Q2","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7QA8X9RDRX2P2CWC59T","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V3ZS9ZS0D7JQFX9T9E22","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7SM1HWCVQSG53QCGEN4","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6W8SBAV1MCTX9KDS7MC","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4BS4FWG5GFXYMS83J18","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4VNS1KFACASNFQGC59H","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7C9MXBDQ13PDVNHPGZK","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6Y9WFR52FHMVKXJPE62","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VAZZ9QX30X2MYM5R71SH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7JJYYWDPM8KSRT5H8GT","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6WC121K6FJ5YSCF1K5E","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7MMG0PPFGXH7750GRAY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6RPVXBTN5VNPKPMZ47A","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4Z1FKPWDNAXZHC09J1Y","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9TB63S1A9C6QA4XXRJD","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7M1XFTCB6HSQS1QA56V","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5BJCWZ0FFWMNAM3YWB1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA565DBWGEK5CY4CN4R8","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7YJFMVBV3EFVQBGBYCY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7GYD0ZJEEPYFQSAWQKV","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4PZ1BJTVVEZYRK75TT3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4Q3FMTNHV7MDHWXTPV6","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA4099RVRJZCEH66ZCVA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4HBJ174BZNQM2T7EKSZ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7Y8EQEMNXPQTK67YYBM","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8QMNX2PC4N2C3D0YRCZ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V58FJSQSMHWEWH4ASXSW","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4QTJ5387220M8VFVRAQ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V446G607JE4V8YJQ2XEE","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9EF9SQ876PT39BBM44Q","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V67QNFSJK6NDS699NFB4","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V90EFQH53NB0GDPGYVP7","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VB3F5G4E69GRMGZ4R7P9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4KBTWXQ61TRMT5H33TA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V76MXBVTCRWGH0ZRV1X4","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V99VMYDC6X01CS88BM7G","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8AYBA3TKQ2CQ6PMCPP8","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V785EB3GJG14N289408C","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5R2TZC7A5R0BCZCKY0A","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V43CCYMNQHV7G958WA2R","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5E9EA0ZBR10Y9J5H9YQ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8YDHDA4NWPNJHY0WNGV","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4TZVRAJ4EK7EF3XEXKK","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9V9WP5EWSZKDNXQSZ8K","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5C2KG5NKPM8SV3QXG1A","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V3WJPB6RXD9B3MNA40TA","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8CEQQ9JSJ0FNVANHS7E","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4EGV0MQWJVN0YT0CJ0N","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4XH5P5Y57BTPTT58KQ8","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V66D10K9F8281XSBK3Y5","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V438C4PS6XZVSW69F7YH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9169MVGCPQG2FXDV3EM","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6RAQSNFGE0YK8SYP286","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5803FNE52DVMN16F1T2","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7YPQPA702S75PTT45SJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V746V1GRS89V1DXN264Q","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8T8CVF65ZDTP9J30YWG","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6YHFGE11PTJGTP5W2H7","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9X4GZWANP2Y1JCY3601","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V569XT20KBNGW8WQB231","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6CYFCE8RSPS54HMF3AD","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5QDP50C98R6MG2NPHEJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VB7DADDNQJ2FKDQY756D","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8DCMRQWANWRHK7G88ET","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9238D2QJW1HX2740JMS","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7W2GCPXQRG2DH2VNX9F","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V72HPYZBTHWRDDG1K9GX","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4CY6ECPFCGV8PJYFB55","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V76RCHDGPDPXJV319ED1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V99KWWMSFBZ379P86H7X","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7H24HHAZGPBC8ZQSGQS","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9K43WQRQ2VP7J7WAQKQ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VB75GFFVA28S8AZNTQGM","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VB71PD13H8VFG8QMCTRY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V913CDTG45KTMZNF5FP1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V78HY15DCJ8ZDDD2A4D8","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8HPBBH7NHJT0C8BQ3A1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7BQXAJ9VW2P4M6VEQQ4","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V82PX0HY3SH0QT395SPH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7AWK4F46T2SFW3CNQ72","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7M9SMAK5AKDZGMVG31B","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V45S5B655YG0N4N2Y9G2","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6QT6E5FDQ3V0GX2VXZ3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V80CQRT1CR23C02J8XRY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V53VVACPC2R4GM9K4Z4S","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V82CP92N37ADEE845NG6","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VAXBRTHDDCBN5CRV7Q03","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V72XR3AE5Y4JQ74QDD61","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VAKYTMNM95ZKZGGX4ND9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5GAZARK4REMZ19D7VP9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4YXZ0A0C4FVPSDVCCX8","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA5Q7MRHPFK2X6VV9WHE","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8TKG9445TN0CQ6SMQTR","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5Z7888KPPE9CZ1Z0K2J","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V516570TYREC4WC63RWE","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9TKWHQVJKA277PV3EE5","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA7AHZSPEB0CQSM77TSJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4PGVRD2VN60VA77DBMJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6E6EDF3CER3JNGN8DYH","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7H6S72WJ8Z5SJGFCA9G","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7YB6PXWNF4CK8PQBJNC","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V779E2MFDBA660FYA4NY","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9JQV2N1C9P13AGP6D61","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5W85BE6CWNSYBYBMWN3","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V3VNAWR02HZAVNBAQDWC","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8MGRVJ83YRX1AY6XR46","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V9WK978WW5HPC18EGDTE","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V6T9K2FYHVRX6H64G0GK","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V5953J42N51S27ZPEMYJ","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4M98HWRX9ZCQFH0292J","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4TWNN35GVTYYB3GPBNT","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8Q6HP5YGQN85CFX11E9","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VA33FVF7VCEWMRS8MK4H","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8FENT5QY959K5ZR4Q0H","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3VBBHTM1VAB6VTAKQA3J1","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V7RH2HPECDJAJJZ4KYCD","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01H29CX1S6PDVEW3WKCC061PZC","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V4B5AR9PNP80SQYANPT2","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8GFHYSGSTZ26NJS2QDF","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"},{"organizationId":"orgn_01GVH3V8QHH54BQE9A81EKX72Q","attributeId":"attr_01GYSVX1NAMR6RDV6M69H4KN3T"}],"updateText":[{"text":"The ACLU of Kentucky has limited resources and unfortunately can only take cases that raise significant constitutional issues or issues of civil liberties. If your situation is not something the ACLU of Kentucky handles, please visit ACLU-KY.org/Referrals.","key":"orgn_01GW0KDDPXYAGXM958F8KSN7Y3.attribute.atts_01HA303FPTXY15ANMFH864FSP4"},{"text":"All services are offered virtually; there is no physical address.","key":"orgn_01GVH3V8BSR9HAB665YRYBGTKP.attribute.atts_01HA303FKC5C36BHNN1JMZXE8J"},{"text":"CHN Sutphin Blvd. is temporarily closed for construction. You can access all services at the nearby CHN Jamaica health center at 89-44 164th Street Jamaica, NY 11432.","key":"orgn_01GVH3V55SZ2XKX0DMR185KQM1.attribute.atts_01HA303FE11TK4BA92NP42AF7Q"},{"text":"Satellite offices in Simcoe County are closed to walk-ins and all other face-to-face appointments until further notice. Appointments at the main office in Orillia are available for urgent matters. For assistance please email or call 1-800-461-8953, Ext. 0. during regular office hours. If you live in the City of Kawartha Lakes or Haliburton County, please call or text 705-879-3610.","key":"orgn_01GVH3V661DAV1MECH5EYPCAGH.attribute.atts_01HA303FG7K8CDACDJYZ51TX8H"},{"text":"Community of Hope is not able to directly place families and individuals into their housing programs. They can provide assistance to access other local resources and programs. For more information, please contact their Bellevue Family Success Center.","key":"orgn_01GVH3V9HWXJMSE5R0F9QWV67J.attribute.atts_01HA303FN7YM2ZN6T0H224J86V"},{"text":"Ward 4 Mutual Aid is only open one Saturday each month. Check their website for details.","key":"orgn_01GVH3V9HSV8WQANN39GYPS98F.attribute.atts_01HA303FN7BT5KSXN4311A6AQW"}]} \ No newline at end of file diff --git a/packages/db/prisma/data-migrations/2023-09-22_update-alerts/index.ts b/packages/db/prisma/data-migrations/2023-09-22_update-alerts/index.ts new file mode 100644 index 00000000000..8a72fbf89e7 --- /dev/null +++ b/packages/db/prisma/data-migrations/2023-09-22_update-alerts/index.ts @@ -0,0 +1,70 @@ +import { z } from 'zod' + +import fs from 'fs' +import path from 'path' + +import { prisma } from '~db/client' +import { formatMessage } from '~db/prisma/common' +import { type MigrationJob } from '~db/prisma/dataMigrationRunner' +import { createLogger, type JobDef, jobPostRunner } from '~db/prisma/jobPreRun' + +/** Define the job metadata here. */ +const jobDef: JobDef = { + jobId: '2023-09-22-update-alerts', + title: 'update alerts', + createdBy: 'Joe Karow', + /** Optional: Longer description for the job */ + description: undefined, +} + +const Schema = z.object({ + deactivate: z.object({ attributeId: z.string(), organizationId: z.string() }).array(), + updateText: z.object({ key: z.string(), text: z.string() }).array(), +}) +/** Job export - this variable MUST be UNIQUE */ +export const job20230922_update_alerts = { + title: `[${jobDef.jobId}] ${jobDef.title}`, + task: async (_ctx, task) => { + /** 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/` + */ + + // Do stuff + const { deactivate, updateText } = Schema.parse( + JSON.parse(fs.readFileSync(path.resolve(__dirname, './data.json'), 'utf-8')) + ) + + const deactivatedAlerts = await prisma.$transaction( + deactivate.map((ids) => + prisma.organizationAttribute.update({ + where: { organizationId_attributeId: ids }, + data: { active: false }, + }) + ) + ) + + log(`Deactivated alerts: ${deactivatedAlerts.length}`) + + const updatedAlertText = await prisma.$transaction( + updateText.map(({ key, text }) => + prisma.translationKey.update({ where: { ns_key: { key, ns: 'org-data' } }, data: { text } }) + ) + ) + log(`Alerts updated: ${updatedAlertText.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 diff --git a/packages/db/prisma/data-migrations/index.ts b/packages/db/prisma/data-migrations/index.ts index 5599121eab5..05a6738384d 100644 --- a/packages/db/prisma/data-migrations/index.ts +++ b/packages/db/prisma/data-migrations/index.ts @@ -51,4 +51,6 @@ export * from './2023-09-18_enable-and-sort-languages' export * from './2023-09-19_add-orgs-trans-relo-support/index' export * from './2023-09-20_fix-access-instructions/index' export * from './2023-09-20_update-services' +export * from './2023-09-22_service-areas' +export * from './2023-09-22_update-alerts/index' // codegen:end