Files
starr-philproperties/database/migrations/20260709000004-add-task-review-assign-complete-notification-templates.js
T

43 lines
1.6 KiB
JavaScript

'use strict';
// Part 1A/1C — new learner-facing notification types for the task review
// workflow, group assignment, and per-task completion. Seeded already-published
// (status: 'sent') like every other is_system row in the original
// 20260703000008 migration, so the trigger call sites work immediately without
// requiring an admin to publish them first.
module.exports = {
async up(queryInterface) {
const now = new Date();
await queryInterface.bulkInsert('notification_templates', [
{
type: 'task_submission_reviewed', notify_type: 'task', scope: 'user', is_system: true,
label: 'Task Submission Reviewed', status: 'sent',
title: 'Submission Reviewed',
message: 'Your submission for "{{taskName}}" was {{statusLabel}}.{{reviewNoteSuffix}}',
createdAt: now, updatedAt: now,
},
{
type: 'task_assigned', notify_type: 'task', scope: 'user', is_system: true,
label: 'Task List Assigned', status: 'sent',
title: 'New Task Assigned',
message: 'You have been assigned "{{taskListName}}" — {{taskCount}} task(s) to complete.',
createdAt: now, updatedAt: now,
},
{
type: 'task_completed', notify_type: 'task', scope: 'user', is_system: true,
label: 'Task Completed', status: 'sent',
title: 'Task Completed',
message: 'You completed "{{taskName}}".',
createdAt: now, updatedAt: now,
},
]);
},
async down(queryInterface) {
await queryInterface.bulkDelete('notification_templates', {
type: ['task_submission_reviewed', 'task_assigned', 'task_completed'],
});
},
};