Skip to content

Commit 0592bf5

Browse files
Fix bandwidth constraint errors (#10211)
* Fix bandwidth constraint errors Signed-off-by: Artem Savchenko <[email protected]> * Clean up Signed-off-by: Artem Savchenko <[email protected]> --------- Signed-off-by: Artem Savchenko <[email protected]>
1 parent a8a4b90 commit 0592bf5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

services/billing/pod-billing/src/db/migrations.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515

1616
export function getMigrations (): [string, string][] {
17-
return [migrationV1(), migrationV2()]
17+
return [migrationV1(), migrationV2(), migrationV3()]
1818
}
1919

2020
function migrationV1 (): [string, string] {
@@ -77,3 +77,11 @@ function migrationV2 (): [string, string] {
7777
`
7878
return ['init_ai_usage_tables_02', sql]
7979
}
80+
81+
function migrationV3 (): [string, string] {
82+
const sql = `
83+
UPDATE billing.livekit_session SET bandwidth = 0 WHERE bandwidth IS NULL;
84+
ALTER TABLE billing.livekit_session ALTER COLUMN bandwidth SET DEFAULT 0;
85+
`
86+
return ['fix_bandwidth_nulls_03', sql]
87+
}

services/billing/pod-billing/src/db/postgres.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class PostgresDB implements BillingDB {
204204
values.push(
205205
`($${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++}, $${paramIndex++})`
206206
)
207-
params.push(workspace, sessionId, sessionStart, sessionEnd, room, bandwidth, minutes)
207+
params.push(workspace, sessionId, sessionStart, sessionEnd, room, bandwidth ?? 0, minutes)
208208
}
209209

210210
if (values.length === 0) continue

0 commit comments

Comments
 (0)