From 48613558d4a3c2a0d6a38a4185433b8069c53191 Mon Sep 17 00:00:00 2001 From: yangjianbo Date: Sun, 11 Jan 2026 19:01:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E7=9B=98):=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=88=86=E5=8C=BA=E8=BF=81=E7=A7=BB=E4=B8=8E=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/usage_log_repo_integration_test.go | 2 +- backend/migrations/035_usage_logs_partitioning.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/internal/repository/usage_log_repo_integration_test.go b/backend/internal/repository/usage_log_repo_integration_test.go index e1c8085e..51964782 100644 --- a/backend/internal/repository/usage_log_repo_integration_test.go +++ b/backend/internal/repository/usage_log_repo_integration_test.go @@ -311,7 +311,7 @@ func (s *UsageLogRepoSuite) TestDashboardStatsWithRange_Fallback() { now := time.Now().UTC() todayStart := truncateToDayUTC(now) rangeStart := todayStart.Add(-24 * time.Hour) - rangeEnd := now + rangeEnd := now.Add(1 * time.Second) user1 := mustCreateUser(s.T(), s.client, &service.User{Email: "range-u1@test.com"}) user2 := mustCreateUser(s.T(), s.client, &service.User{Email: "range-u2@test.com"}) diff --git a/backend/migrations/035_usage_logs_partitioning.sql b/backend/migrations/035_usage_logs_partitioning.sql index 5919b5c3..e25a105e 100644 --- a/backend/migrations/035_usage_logs_partitioning.sql +++ b/backend/migrations/035_usage_logs_partitioning.sql @@ -1,6 +1,6 @@ -- usage_logs monthly partition bootstrap. --- Only converts to partitioned table when usage_logs is empty. --- Existing installations with data require a manual migration plan. +-- Only creates partitions when usage_logs is already partitioned. +-- Converting usage_logs to a partitioned table requires a manual migration plan. DO $$ DECLARE @@ -20,8 +20,8 @@ BEGIN IF NOT is_partitioned THEN SELECT EXISTS(SELECT 1 FROM usage_logs LIMIT 1) INTO has_data; IF NOT has_data THEN - EXECUTE 'ALTER TABLE usage_logs PARTITION BY RANGE (created_at)'; - is_partitioned := TRUE; + -- Automatic conversion is intentionally skipped; see manual migration plan. + RAISE NOTICE 'usage_logs is not partitioned; skip automatic partitioning'; END IF; END IF;