From 8425e480057b5723962614056ff86c24801e056b Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 14 Nov 2025 17:09:54 +0700 Subject: [PATCH 1/2] Fix bandwidth constraint errors Signed-off-by: Artem Savchenko --- services/billing/pod-billing/src/db/migrations.ts | 12 ++++++++++-- services/billing/pod-billing/src/db/postgres.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/services/billing/pod-billing/src/db/migrations.ts b/services/billing/pod-billing/src/db/migrations.ts index e2a3921343f..b17da1bbf38 100644 --- a/services/billing/pod-billing/src/db/migrations.ts +++ b/services/billing/pod-billing/src/db/migrations.ts @@ -14,7 +14,7 @@ // export function getMigrations (): [string, string][] { - return [migrationV1(), migrationV2()] + return [migrationV1(), migrationV2(), migrationV3()] } function migrationV1 (): [string, string] { @@ -25,7 +25,7 @@ function migrationV1 (): [string, string] { session_start TIMESTAMP NOT NULL, session_end TIMESTAMP NOT NULL, room STRING(255) NOT NULL, - bandwidth INT8 NOT NULL, + bandwidth INT8 NOT NULL DEFAULT 0, minutes INT8 NOT NULL, CONSTRAINT pk_livekit_session PRIMARY KEY (workspace, session_id) ); @@ -77,3 +77,11 @@ function migrationV2 (): [string, string] { ` return ['init_ai_usage_tables_02', sql] } + +function migrationV3 (): [string, string] { + const sql = ` + UPDATE billing.livekit_session SET bandwidth = 0 WHERE bandwidth IS NULL; + ALTER TABLE billing.livekit_session ALTER COLUMN bandwidth SET DEFAULT 0; + ` + return ['fix_bandwidth_nulls_03', sql] +} diff --git a/services/billing/pod-billing/src/db/postgres.ts b/services/billing/pod-billing/src/db/postgres.ts index 557e747cd71..bf0b13ebaaf 100644 --- a/services/billing/pod-billing/src/db/postgres.ts +++ b/services/billing/pod-billing/src/db/postgres.ts @@ -204,7 +204,7 @@ class PostgresDB implements BillingDB { values.push( `($${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++})` ) - params.push(workspace, sessionId, sessionStart, sessionEnd, room, bandwidth, minutes) + params.push(workspace, sessionId, sessionStart, sessionEnd, room, bandwidth ?? 0, minutes) } if (values.length === 0) continue From 0c1694d0b36a2b5e6d85b605f087bc404a806fd1 Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 14 Nov 2025 17:27:05 +0700 Subject: [PATCH 2/2] Clean up Signed-off-by: Artem Savchenko --- services/billing/pod-billing/src/db/migrations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/billing/pod-billing/src/db/migrations.ts b/services/billing/pod-billing/src/db/migrations.ts index b17da1bbf38..97539332c94 100644 --- a/services/billing/pod-billing/src/db/migrations.ts +++ b/services/billing/pod-billing/src/db/migrations.ts @@ -25,7 +25,7 @@ function migrationV1 (): [string, string] { session_start TIMESTAMP NOT NULL, session_end TIMESTAMP NOT NULL, room STRING(255) NOT NULL, - bandwidth INT8 NOT NULL DEFAULT 0, + bandwidth INT8 NOT NULL, minutes INT8 NOT NULL, CONSTRAINT pk_livekit_session PRIMARY KEY (workspace, session_id) );