Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
70 lines
2.4 KiB
JavaScript
70 lines
2.4 KiB
JavaScript
/**
|
|
* Migration: Add SLA Email notification category, subtypes, and templates.
|
|
*
|
|
* Creates email notification infrastructure for SLA alerts:
|
|
* - SLA category in notification_categories
|
|
* - Subtypes: SLA Warning, SLA Breach, SLA Escalation
|
|
* - English email templates with HTML and text versions
|
|
*
|
|
* Uses the shared source-of-truth template pattern.
|
|
*/
|
|
|
|
const { upsertEmailCategoriesAndSubtypes } = require('./utils/templates/_shared/emailCategoriesAndSubtypes.cjs');
|
|
const { upsertEmailTemplate } = require('./utils/templates/_shared/upsertEmailTemplates.cjs');
|
|
const { getTemplate: slaWarning } = require('./utils/templates/email/sla/slaWarning.cjs');
|
|
const { getTemplate: slaBreach } = require('./utils/templates/email/sla/slaBreach.cjs');
|
|
const { getTemplate: slaEscalation } = require('./utils/templates/email/sla/slaEscalation.cjs');
|
|
|
|
const SLA_TEMPLATES = [slaWarning, slaBreach, slaEscalation];
|
|
|
|
exports.up = async function(knex) {
|
|
console.log('Adding SLA email notification category, subtypes, and templates...');
|
|
|
|
// 1. Upsert all email notification categories & subtypes (including SLA)
|
|
await upsertEmailCategoriesAndSubtypes(knex);
|
|
console.log(' ✓ Email categories & subtypes upserted');
|
|
|
|
// 2. Upsert SLA email templates from source-of-truth
|
|
for (const getter of SLA_TEMPLATES) {
|
|
const def = getter();
|
|
await upsertEmailTemplate(knex, def);
|
|
}
|
|
console.log(` ✓ ${SLA_TEMPLATES.length} SLA email templates upserted`);
|
|
|
|
console.log('Successfully added SLA email notification templates');
|
|
};
|
|
|
|
exports.down = async function(knex) {
|
|
console.log('Removing SLA email notification templates...');
|
|
|
|
// Delete templates
|
|
await knex('system_email_templates')
|
|
.whereIn('name', ['sla-warning', 'sla-breach', 'sla-escalation'])
|
|
.delete();
|
|
|
|
// Delete subtypes
|
|
await knex('notification_subtypes')
|
|
.whereIn('name', ['SLA Warning', 'SLA Breach', 'SLA Escalation'])
|
|
.delete();
|
|
|
|
// Delete category if empty
|
|
const slaCategory = await knex('notification_categories')
|
|
.where({ name: 'SLA' })
|
|
.first();
|
|
|
|
if (slaCategory) {
|
|
const remainingSubtypes = await knex('notification_subtypes')
|
|
.where({ category_id: slaCategory.id })
|
|
.count('* as count')
|
|
.first();
|
|
|
|
if (Number(remainingSubtypes?.count || 0) === 0) {
|
|
await knex('notification_categories')
|
|
.where({ name: 'SLA' })
|
|
.delete();
|
|
}
|
|
}
|
|
|
|
console.log('Successfully removed SLA email notification templates');
|
|
};
|