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
89 lines
3.3 KiB
JavaScript
89 lines
3.3 KiB
JavaScript
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.up = async function(knex) {
|
|
// Add missing phone codes for countries and territories with distinct dialing codes
|
|
const missingPhoneCodeUpdates = [
|
|
// Missing Caribbean and North American territories
|
|
['AI', '+1264'], // Anguilla
|
|
['BL', '+590'], // Saint Barthélemy
|
|
['VG', '+1284'], // British Virgin Islands
|
|
['MS', '+1664'], // Montserrat
|
|
['GP', '+590'], // Guadeloupe
|
|
['MQ', '+596'], // Martinique
|
|
['PM', '+508'], // Saint Pierre and Miquelon
|
|
['MF', '+590'], // Saint Martin (French part)
|
|
|
|
// Missing European territories with distinct codes
|
|
['AX', '+358'], // Åland Islands (uses Finland +358 but distinct routing)
|
|
['FO', '+298'], // Faroe Islands
|
|
['GG', '+44'], // Guernsey (uses UK +44 but distinct routing)
|
|
['IM', '+44'], // Isle of Man (uses UK +44 but distinct routing)
|
|
['JE', '+44'], // Jersey (uses UK +44 but distinct routing)
|
|
['GI', '+350'], // Gibraltar
|
|
['GL', '+299'], // Greenland
|
|
|
|
// Missing African countries and territories
|
|
['EH', '+212'], // Western Sahara (uses Morocco routing)
|
|
['MR', '+222'], // Mauritania (sovereign country that was missing)
|
|
|
|
// Missing Pacific territories with distinct codes
|
|
['CC', '+61'], // Cocos (Keeling) Islands (uses Australia +61 but distinct routing)
|
|
['CX', '+61'], // Christmas Island (uses Australia +61 but distinct routing)
|
|
['NF', '+672'], // Norfolk Island
|
|
['PN', '+64'], // Pitcairn Islands (uses New Zealand routing)
|
|
['UM', '+1'], // United States Minor Outlying Islands
|
|
|
|
// Missing South Atlantic with distinct codes
|
|
['GS', '+500'], // South Georgia and the South Sandwich Islands
|
|
|
|
// Missing sovereign countries
|
|
['TL', '+670'], // Timor-Leste
|
|
|
|
// Missing special territories (from deleted migration 20250915000001)
|
|
['BV', '+47'], // Bouvet Island (uses Norway routing)
|
|
['HM', '+672'], // Heard Island and McDonald Islands
|
|
['IO', '+246'], // British Indian Ocean Territory
|
|
['SJ', '+47'], // Svalbard and Jan Mayen (uses Norway routing)
|
|
['TF', '+262'], // French Southern Territories
|
|
];
|
|
|
|
// Update countries with missing phone codes using bulk UPDATE with CASE WHEN
|
|
// Note: countries is a reference table (shared across all tenants), so no tenant filter needed
|
|
if (missingPhoneCodeUpdates.length > 0) {
|
|
const codes = missingPhoneCodeUpdates.map(([code]) => code);
|
|
const caseWhen = missingPhoneCodeUpdates
|
|
.map(([code, phone]) => `WHEN '${code}' THEN '${phone}'`)
|
|
.join(' ');
|
|
|
|
await knex.raw(`
|
|
UPDATE countries
|
|
SET phone_code = CASE code ${caseWhen} END
|
|
WHERE code IN (${codes.map(code => `'${code}'`).join(', ')})
|
|
`);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.down = async function(knex) {
|
|
// Remove the phone codes we added
|
|
const countriesToClear = [
|
|
'AI', 'BL', 'VG', 'MS', 'GP', 'MQ', 'PM', 'MF',
|
|
'AX', 'FO', 'GG', 'IM', 'JE', 'GI', 'GL',
|
|
'EH', 'MR',
|
|
'CC', 'CX', 'NF', 'PN', 'UM',
|
|
'GS', 'TL',
|
|
'BV', 'HM', 'IO', 'SJ', 'TF'
|
|
];
|
|
|
|
// Note: countries is a reference table (shared across all tenants), so no tenant filter needed
|
|
for (const countryCode of countriesToClear) {
|
|
await knex('countries')
|
|
.where('code', countryCode)
|
|
.update({ phone_code: null });
|
|
}
|
|
}; |