This commit is contained in:
2026-06-26 12:40:16 +03:30
parent 6d16a7dde5
commit 1f74019eaf
5 changed files with 38 additions and 30 deletions
+10 -3
View File
@@ -5,7 +5,7 @@ export class Migration20260626140000 extends Migration {
override async up(): Promise<void> {
this.addSql(`
alter table "invoices"
add column "confirm_status" text check ("confirm_status" in ('pending', 'confirmed')) not null default 'pending';
add column "confirm_status" text check ("confirm_status" in ('pending', 'partially_confirmed', 'confirmed')) not null default 'pending';
`);
this.addSql(`
@@ -55,14 +55,21 @@ export class Migration20260626140000 extends Migration {
AND deleted_at IS NULL;
SELECT CASE
WHEN EXISTS (
WHEN NOT EXISTS (
SELECT 1
FROM invoice_items
WHERE invoice_id = v_invoice_id
AND deleted_at IS NULL
AND confirmed_at IS NOT NULL
) THEN 'pending'
WHEN NOT EXISTS (
SELECT 1
FROM invoice_items
WHERE invoice_id = v_invoice_id
AND deleted_at IS NULL
AND confirmed_at IS NULL
) THEN 'confirmed'
ELSE 'pending'
ELSE 'partially_confirmed'
END
INTO v_confirm_status;