Skip to content

Commit

Permalink
Add some helpful fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thewatermethod committed Oct 29, 2024
1 parent 1aeb882 commit 26494f1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/migrations/20241024002207-insert-standard-goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const standardGoalTexts = [
'(Disaster Recovery) The recipient will implement systems and services to support children, families, and staff with recovering from disasters.',
'(RAN investigation) The recipient will implement systems and services to address a reported child incident during the RO investigation.',
];

const now = new Date();

const standardGoal = (templateName) => ({
creationMethod: CREATION_METHOD.CURATED,
hash: md5(templateName),
createdAt: new Date(),
updatedAt: new Date(),
templateNameModifiedAt: new Date(),
createdAt: now,
updatedAt: now,
templateNameModifiedAt: now,
});

const standardGoalTemplates = standardGoalTexts.map((templateName) => ({
Expand All @@ -47,10 +50,14 @@ module.exports = {
async (transaction) => {
await prepMigration(queryInterface, transaction, __filename);

await queryInterface.sequelize.query(`
DELETE FROM "GoalTemplates"
WHERE "creationMethod" = '${CREATION_METHOD.CURATED}' AND "templateName" IN (${standardGoalTexts.map((templateName) => `'${templateName}'`).join(',')});
`, { transaction });
await queryInterface.bulkDelete(
'GoalTemplates',
{
creationMethod: CREATION_METHOD.CURATED,
templateName: standardGoalTexts.map((templateName) => templateName),
},
{ transaction },
);
},
),
};

0 comments on commit 26494f1

Please sign in to comment.