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
44 lines
1.7 KiB
JavaScript
44 lines
1.7 KiB
JavaScript
/**
|
|
* Widen invoice_charge_details.quantity from integer to numeric(10,2).
|
|
*
|
|
* Hourly time charges now bill fractional hours (e.g. 4.25h) instead of
|
|
* rounding each time entry up to a whole hour. invoice_charges.quantity and the
|
|
* invoice_items view were already numeric(10,2) (migration 20250225165701), but
|
|
* the detail/breakdown table — formerly invoice_item_details, renamed to
|
|
* invoice_charge_details — was missed and still rejected fractional quantities
|
|
* with `invalid input syntax for type integer: "4.25"` when persisting the
|
|
* recurring service-period detail row.
|
|
*
|
|
* `rate` on this table stays integer: it stores whole cents.
|
|
*
|
|
* Citus note: invoice_charge_details is a distributed table. Force sequential
|
|
* multi-shard modification first so the type change applies cleanly across all
|
|
* shards within the migration transaction.
|
|
*/
|
|
|
|
const isCitusEnabled = async (knex) => {
|
|
const r = await knex.raw("SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'citus') AS enabled");
|
|
return Boolean(r.rows?.[0]?.enabled);
|
|
};
|
|
|
|
exports.up = async function (knex) {
|
|
if (await isCitusEnabled(knex)) {
|
|
await knex.raw("SET LOCAL citus.multi_shard_modify_mode TO 'sequential'");
|
|
}
|
|
|
|
await knex.raw(
|
|
'ALTER TABLE invoice_charge_details ALTER COLUMN quantity TYPE numeric(10,2) USING quantity::numeric(10,2)'
|
|
);
|
|
};
|
|
|
|
exports.down = async function (knex) {
|
|
if (await isCitusEnabled(knex)) {
|
|
await knex.raw("SET LOCAL citus.multi_shard_modify_mode TO 'sequential'");
|
|
}
|
|
|
|
// Best-effort revert: fractional quantities are rounded back to whole units.
|
|
await knex.raw(
|
|
'ALTER TABLE invoice_charge_details ALTER COLUMN quantity TYPE integer USING round(quantity)::integer'
|
|
);
|
|
};
|