PSA/server/migrations/20251119000000_add_webhook_config_columns.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

53 lines
2.4 KiB
JavaScript

/**
* Add webhook configuration columns to vendor-specific email provider config tables
* These columns were previously assumed to exist or were part of an older schema.
*/
exports.up = async function(knex) {
const addColumnIfNotExists = async (tableName, columnName, type) => {
const exists = await knex.schema.hasColumn(tableName, columnName);
if (!exists) {
await knex.schema.table(tableName, (table) => {
if (type === 'timestamp') {
table.timestamp(columnName).nullable();
} else {
table.text(columnName).nullable();
}
});
}
};
// Add columns to microsoft_email_provider_config
await addColumnIfNotExists('microsoft_email_provider_config', 'webhook_subscription_id', 'text');
await addColumnIfNotExists('microsoft_email_provider_config', 'webhook_verification_token', 'text');
await addColumnIfNotExists('microsoft_email_provider_config', 'webhook_expires_at', 'timestamp');
await addColumnIfNotExists('microsoft_email_provider_config', 'last_subscription_renewal', 'timestamp');
// Add columns to google_email_provider_config
await addColumnIfNotExists('google_email_provider_config', 'webhook_subscription_id', 'text');
await addColumnIfNotExists('google_email_provider_config', 'webhook_verification_token', 'text');
await addColumnIfNotExists('google_email_provider_config', 'webhook_expires_at', 'timestamp');
await addColumnIfNotExists('google_email_provider_config', 'last_subscription_renewal', 'timestamp');
console.log('✅ Added webhook configuration columns to vendor email config tables (idempotent)');
};
exports.down = async function(knex) {
// Drop columns from microsoft_email_provider_config
await knex.schema.table('microsoft_email_provider_config', function(table) {
table.dropColumn('webhook_subscription_id');
table.dropColumn('webhook_verification_token');
table.dropColumn('webhook_expires_at');
table.dropColumn('last_subscription_renewal');
});
// Drop columns from google_email_provider_config
await knex.schema.table('google_email_provider_config', function(table) {
table.dropColumn('webhook_subscription_id');
table.dropColumn('webhook_verification_token');
table.dropColumn('webhook_expires_at');
table.dropColumn('last_subscription_renewal');
});
console.log('✅ Dropped webhook configuration columns from vendor email config tables');
};