Skip to content

Commit 8850ce0

Browse files
authored
fix: use bigint instead of integer in stats migration (#6380)
This broke dogfood!
1 parent 05e4499 commit 8850ce0

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

coderd/database/dump.sql

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
ALTER TABLE agent_stats RENAME TO workspace_agent_stats;
22

33
ALTER TABLE workspace_agent_stats ADD COLUMN connections_by_proto jsonb NOT NULL DEFAULT '{}'::jsonb;
4-
ALTER TABLE workspace_agent_stats ADD COLUMN connection_count integer DEFAULT 0 NOT NULL;
5-
ALTER TABLE workspace_agent_stats ADD COLUMN rx_packets integer DEFAULT 0 NOT NULL;
6-
ALTER TABLE workspace_agent_stats ADD COLUMN rx_bytes integer DEFAULT 0 NOT NULL;
7-
ALTER TABLE workspace_agent_stats ADD COLUMN tx_packets integer DEFAULT 0 NOT NULL;
8-
ALTER TABLE workspace_agent_stats ADD COLUMN tx_bytes integer DEFAULT 0 NOT NULL;
4+
ALTER TABLE workspace_agent_stats ADD COLUMN connection_count bigint DEFAULT 0 NOT NULL;
5+
ALTER TABLE workspace_agent_stats ADD COLUMN rx_packets bigint DEFAULT 0 NOT NULL;
6+
ALTER TABLE workspace_agent_stats ADD COLUMN rx_bytes bigint DEFAULT 0 NOT NULL;
7+
ALTER TABLE workspace_agent_stats ADD COLUMN tx_packets bigint DEFAULT 0 NOT NULL;
8+
ALTER TABLE workspace_agent_stats ADD COLUMN tx_bytes bigint DEFAULT 0 NOT NULL;
99

1010
UPDATE workspace_agent_stats SET
1111
connections_by_proto = coalesce((payload ->> 'conns_by_proto')::jsonb, '{}'::jsonb),
12-
connection_count = coalesce((payload ->> 'num_conns')::integer, 0),
13-
rx_packets = coalesce((payload ->> 'rx_packets')::integer, 0),
14-
rx_bytes = coalesce((payload ->> 'rx_bytes')::integer, 0),
15-
tx_packets = coalesce((payload ->> 'tx_packets')::integer, 0),
16-
tx_bytes = coalesce((payload ->> 'tx_bytes')::integer, 0);
12+
connection_count = coalesce((payload ->> 'num_conns')::bigint, 0),
13+
rx_packets = coalesce((payload ->> 'rx_packets')::bigint, 0),
14+
rx_bytes = coalesce((payload ->> 'rx_bytes')::bigint, 0),
15+
tx_packets = coalesce((payload ->> 'tx_packets')::bigint, 0),
16+
tx_bytes = coalesce((payload ->> 'tx_bytes')::bigint, 0);
1717

1818
ALTER TABLE workspace_agent_stats DROP COLUMN payload;

coderd/database/models.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceagents.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,11 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
948948
UserID: workspace.OwnerID,
949949
TemplateID: workspace.TemplateID,
950950
ConnectionsByProto: payload,
951-
ConnectionCount: int32(req.ConnectionCount),
952-
RxPackets: int32(req.RxPackets),
953-
RxBytes: int32(req.RxBytes),
954-
TxPackets: int32(req.TxPackets),
955-
TxBytes: int32(req.TxBytes),
951+
ConnectionCount: req.ConnectionCount,
952+
RxPackets: req.RxPackets,
953+
RxBytes: req.RxBytes,
954+
TxPackets: req.TxPackets,
955+
TxBytes: req.TxBytes,
956956
})
957957
if err != nil {
958958
httpapi.InternalServerError(rw, err)

0 commit comments

Comments
 (0)