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
88 lines
2.9 KiB
JavaScript
88 lines
2.9 KiB
JavaScript
/**
|
|
* Drop the tenant_settings updated_at trigger since the backend already handles
|
|
* updating the updated_at column explicitly in all update operations.
|
|
* This follows the pattern established in other migrations of moving trigger
|
|
* logic to application code for better control and Citus compatibility.
|
|
*/
|
|
exports.up = async function(knex) {
|
|
let isDistributed = false;
|
|
|
|
// First check if Citus extension exists
|
|
try {
|
|
const citusCheck = await knex.raw(`
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM pg_extension WHERE extname = 'citus'
|
|
) as has_citus
|
|
`);
|
|
|
|
if (citusCheck.rows[0].has_citus) {
|
|
// Only check for distributed table if Citus is installed
|
|
try {
|
|
const result = await knex.raw(`
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM pg_dist_partition
|
|
WHERE logicalrelid = 'tenant_settings'::regclass
|
|
) as is_distributed
|
|
`);
|
|
isDistributed = result.rows[0].is_distributed;
|
|
} catch (error) {
|
|
console.log('Error checking distribution status:', error.message);
|
|
}
|
|
} else {
|
|
console.log('Citus extension not installed - proceeding with trigger drop');
|
|
}
|
|
} catch (error) {
|
|
console.log('Error checking for Citus extension - proceeding with trigger drop');
|
|
}
|
|
|
|
if (isDistributed) {
|
|
console.log('Table tenant_settings is a Citus distributed/reference table - skipping trigger drop');
|
|
} else {
|
|
// Drop the trigger on tenant_settings table
|
|
await knex.raw('DROP TRIGGER IF EXISTS update_tenant_settings_updated_at ON tenant_settings');
|
|
}
|
|
};
|
|
|
|
exports.down = async function(knex) {
|
|
let isDistributed = false;
|
|
|
|
// First check if Citus extension exists
|
|
try {
|
|
const citusCheck = await knex.raw(`
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM pg_extension WHERE extname = 'citus'
|
|
) as has_citus
|
|
`);
|
|
|
|
if (citusCheck.rows[0].has_citus) {
|
|
// Only check for distributed table if Citus is installed
|
|
try {
|
|
const result = await knex.raw(`
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM pg_dist_partition
|
|
WHERE logicalrelid = 'tenant_settings'::regclass
|
|
) as is_distributed
|
|
`);
|
|
isDistributed = result.rows[0].is_distributed;
|
|
} catch (error) {
|
|
console.log('Error checking distribution status:', error.message);
|
|
}
|
|
} else {
|
|
console.log('Citus extension not installed - proceeding with trigger recreation');
|
|
}
|
|
} catch (error) {
|
|
console.log('Error checking for Citus extension - proceeding with trigger recreation');
|
|
}
|
|
|
|
if (isDistributed) {
|
|
console.log('Table tenant_settings is a Citus distributed/reference table - skipping trigger recreation');
|
|
} else {
|
|
// Recreate the trigger if rolling back
|
|
await knex.raw(`
|
|
CREATE TRIGGER update_tenant_settings_updated_at
|
|
BEFORE UPDATE ON tenant_settings
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION update_updated_at_column();
|
|
`);
|
|
}
|
|
}; |