up
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user