diff --git a/services/billing/pod-billing/src/db/migrations.ts b/services/billing/pod-billing/src/db/migrations.ts index e2a3921343f..97539332c94 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] { @@ -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