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
64 lines
2.8 KiB
JavaScript
64 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
const LEGACY_EVENT_TYPES = ['INVOICE_CREATED', 'INVOICE_UPDATED', 'CLIENT_CREATED', 'CLIENT_UPDATED'];
|
|
const LEGACY_WORKFLOW_NAMES = ['QBO Customer Sync', 'qboInvoiceSyncWorkflow', 'qboCustomerSyncWorkflow'];
|
|
|
|
exports.up = async function up(knex) {
|
|
// Citus needs sequential multi-shard modifications when mixing reference/distributed tables.
|
|
const { rows: citusExtension } = await knex.raw("SELECT 1 FROM pg_catalog.pg_extension WHERE extname = 'citus' LIMIT 1");
|
|
if (citusExtension.length > 0) {
|
|
await knex.raw("SET LOCAL citus.multi_shard_modify_mode TO 'sequential'");
|
|
}
|
|
|
|
// Remove tenant-scoped workflow attachments tied to legacy QBO events
|
|
await knex('workflow_event_attachments')
|
|
.whereIn('event_type', LEGACY_EVENT_TYPES)
|
|
.del();
|
|
|
|
// Remove system workflow attachments tied to the same legacy events
|
|
const systemAttachmentIds = await knex('system_workflow_event_attachments')
|
|
.select('system_workflow_event_attachments.attachment_id')
|
|
.join('event_catalog', 'system_workflow_event_attachments.event_id', 'event_catalog.event_id')
|
|
.whereIn('event_catalog.event_type', LEGACY_EVENT_TYPES);
|
|
|
|
if (systemAttachmentIds.length > 0) {
|
|
await knex('system_workflow_event_attachments')
|
|
.whereIn(
|
|
'attachment_id',
|
|
systemAttachmentIds.map((row) => row.attachment_id)
|
|
)
|
|
.del();
|
|
}
|
|
|
|
// Remove system workflow registrations for legacy QBO workflows
|
|
const legacySystemWorkflows = await knex('system_workflow_registrations')
|
|
.whereIn('name', LEGACY_WORKFLOW_NAMES)
|
|
.select('registration_id');
|
|
|
|
if (legacySystemWorkflows.length > 0) {
|
|
const registrationIds = legacySystemWorkflows.map((row) => row.registration_id);
|
|
|
|
await knex('system_workflow_event_attachments').whereIn('workflow_id', registrationIds).del();
|
|
await knex('system_workflow_registration_versions').whereIn('registration_id', registrationIds).del();
|
|
await knex('system_workflow_registrations').whereIn('registration_id', registrationIds).del();
|
|
}
|
|
|
|
// Remove any tenant workflow registrations that still reference the legacy names
|
|
const legacyTenantWorkflows = await knex('workflow_registrations')
|
|
.whereIn('name', LEGACY_WORKFLOW_NAMES)
|
|
.select('registration_id');
|
|
|
|
if (legacyTenantWorkflows.length > 0) {
|
|
const tenantRegistrationIds = legacyTenantWorkflows.map((row) => row.registration_id);
|
|
|
|
await knex('workflow_event_attachments').whereIn('workflow_id', tenantRegistrationIds).del();
|
|
await knex('workflow_registration_versions').whereIn('registration_id', tenantRegistrationIds).del();
|
|
await knex('workflow_registrations').whereIn('registration_id', tenantRegistrationIds).del();
|
|
}
|
|
};
|
|
|
|
exports.down = async function down() {
|
|
// Removing legacy workflow integrations is not reversible.
|
|
console.warn('Skipping down migration for remove_qbo_workflow_automation.');
|
|
};
|