This commit is contained in:
2026-06-26 13:24:52 +03:30
parent 1f74019eaf
commit c1931528cf
4 changed files with 53 additions and 2 deletions
@@ -123,6 +123,7 @@ export class Migration20260626140000 extends Migration {
$$ LANGUAGE plpgsql;
`);
this.addSql(`DROP TRIGGER IF EXISTS trg_invoice_items_recalc ON invoice_items;`);
this.addSql(`
CREATE TRIGGER trg_invoice_items_recalc
AFTER INSERT OR UPDATE OR DELETE
@@ -131,6 +132,7 @@ export class Migration20260626140000 extends Migration {
EXECUTE FUNCTION recalc_invoice_totals();
`);
this.addSql(`DROP TRIGGER IF EXISTS trg_payments_recalc ON payments;`);
this.addSql(`
CREATE TRIGGER trg_payments_recalc
AFTER INSERT OR UPDATE OR DELETE
@@ -138,6 +140,12 @@ export class Migration20260626140000 extends Migration {
FOR EACH ROW
EXECUTE FUNCTION recalc_invoice_payments();
`);
this.addSql(`
UPDATE invoice_items
SET quantity = quantity
WHERE deleted_at IS NULL;
`);
}
override async down(): Promise<void> {