From 4c9622e449cc933e27a6cc21d34792315cd2800a Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Thu, 19 Sep 2024 11:54:17 +0200 Subject: [PATCH] task: make count column bigint. (#8183) (#8184) We now have customers that exceed INT capacity, so we need to change this to BIGINT in client_metrics_env_variants_daily as well. Even heavy users only have about 10000 rows here, so should be a quick enough operation. --- .../metrics/client-metrics/client-metrics-store-v2.ts | 2 +- ...19083625-client-metrics-env-variants-daily-to-bigint.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/migrations/20240919083625-client-metrics-env-variants-daily-to-bigint.js diff --git a/src/lib/features/metrics/client-metrics/client-metrics-store-v2.ts b/src/lib/features/metrics/client-metrics/client-metrics-store-v2.ts index 7fa222f44628..4ec3abde5e82 100644 --- a/src/lib/features/metrics/client-metrics/client-metrics-store-v2.ts +++ b/src/lib/features/metrics/client-metrics/client-metrics-store-v2.ts @@ -119,7 +119,7 @@ const variantRowReducerV2 = (acc, tokenRow) => { }; } if (variant) { - acc[key].variants[variant] = count; + acc[key].variants[variant] = Number(count); } return acc; diff --git a/src/migrations/20240919083625-client-metrics-env-variants-daily-to-bigint.js b/src/migrations/20240919083625-client-metrics-env-variants-daily-to-bigint.js new file mode 100644 index 000000000000..31f1f0c78c0d --- /dev/null +++ b/src/migrations/20240919083625-client-metrics-env-variants-daily-to-bigint.js @@ -0,0 +1,7 @@ +exports.up = function(db, cb) { + db.runSql(`ALTER TABLE client_metrics_env_variants_daily ALTER COLUMN count TYPE BIGINT`, cb); +}; + +exports.down = function(db, cb) { + db.runSql(`ALTER TABLE client_metrics_env_variants_daily ALTER COLUMN count TYPE INT`, cb); +};