PSA/server/seeds/dev/85_itil_priorities.cjs
Hermes 284313f908
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
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

87 lines
2.6 KiB
JavaScript

/**
* Development seed to create test ITIL board with priorities
* This is for development/testing only - actual ITIL standards come from migrations
*/
exports.seed = async function(knex) {
const tenant = await knex('tenants').first();
if (!tenant) {
console.log('No tenant found, skipping ITIL board creation');
return;
}
// Check if ITIL test board already exists
const itilBoard = await knex('boards')
.where('tenant', tenant.tenant)
.where('board_name', 'ITIL Support')
.first();
if (itilBoard) {
console.log('ITIL Support board already exists, skipping...');
return;
}
// Create ITIL-enabled board for testing
const boardId = knex.raw('gen_random_uuid()');
await knex('boards').insert({
board_id: boardId,
tenant: tenant.tenant,
board_name: 'ITIL Support',
description: 'ITIL-compliant support board for testing',
category_type: 'itil',
priority_type: 'itil',
display_itil_impact: true,
display_itil_urgency: true,
display_priority: true,
display_category: true,
display_subcategory: true,
display_order: 100,
is_default: false,
is_inactive: false
});
console.log('Created ITIL Support board for testing');
const createdByUser = await knex('users')
.where('tenant', tenant.tenant)
.orderBy('created_at')
.first();
if (!createdByUser) {
console.log('No user found for tenant, skipping ITIL priorities seed');
return;
}
// Copy ITIL priorities from standard_priorities to tenant's priorities table
// This simulates what should happen automatically when an ITIL board is created
const itilStandardPriorities = await knex('standard_priorities')
.where('is_itil_standard', true)
.select('*');
for (const stdPriority of itilStandardPriorities) {
// Check if already exists in tenant priorities
const existing = await knex('priorities')
.where('tenant', tenant.tenant)
.where('priority_name', stdPriority.priority_name)
.where('item_type', stdPriority.item_type)
.first();
if (!existing) {
await knex('priorities').insert({
priority_id: knex.raw('gen_random_uuid()'),
tenant: tenant.tenant,
priority_name: stdPriority.priority_name,
color: stdPriority.color,
order_number: stdPriority.order_number,
is_from_itil_standard: true,
itil_priority_level: stdPriority.itil_priority_level,
item_type: stdPriority.item_type,
created_by: createdByUser.user_id,
created_at: knex.fn.now()
});
}
}
console.log('Copied ITIL priorities to tenant for testing');
};