From 6a913701b9543c104f211bc2ce4574218e849c8d Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 16 Jun 2026 08:57:35 +0800 Subject: [PATCH] refactor(push): remove legacy push_global_token setting - Clean up redundant push_global_token INSERT and DELETE statements from 202606140004 migration. - Add DELETE for push_global_token in 202606160001 migration to wipe out legacy settings on update. - Adjust expected w_system_configs count in migrator_test.go to 30. --- .../postgres/202606140004_create_push_channels.sql | 12 ------------ .../postgres/202606160001_remove_push_config.sql | 1 + .../sqlite/202606140004_create_push_channels.sql | 12 ------------ .../goose/sqlite/202606160001_remove_push_config.sql | 1 + internal/db/migrator/migrator_test.go | 2 +- 5 files changed, 3 insertions(+), 25 deletions(-) diff --git a/internal/db/migrator/goose/postgres/202606140004_create_push_channels.sql b/internal/db/migrator/goose/postgres/202606140004_create_push_channels.sql index a6a24e61..72371d86 100644 --- a/internal/db/migrator/goose/postgres/202606140004_create_push_channels.sql +++ b/internal/db/migrator/goose/postgres/202606140004_create_push_channels.sql @@ -15,17 +15,5 @@ CREATE TABLE w_push_channels ( CREATE INDEX idx_w_push_channels_name ON w_push_channels(name); CREATE INDEX idx_w_push_channels_enabled ON w_push_channels(enabled); -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ( - 'push_global_token', - '', - 'system', - 0, - '系统全局推送鉴权令牌', - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -) ON CONFLICT (key) DO NOTHING; - -- +goose Down -DELETE FROM w_system_configs WHERE key = 'push_global_token'; DROP TABLE IF EXISTS w_push_channels; diff --git a/internal/db/migrator/goose/postgres/202606160001_remove_push_config.sql b/internal/db/migrator/goose/postgres/202606160001_remove_push_config.sql index 16efd10e..d3214a00 100644 --- a/internal/db/migrator/goose/postgres/202606160001_remove_push_config.sql +++ b/internal/db/migrator/goose/postgres/202606160001_remove_push_config.sql @@ -1,5 +1,6 @@ -- +goose Up DELETE FROM w_system_configs WHERE key = 'push_config'; DELETE FROM w_push_events WHERE event_key = 'admin_login'; +DELETE FROM w_system_configs WHERE key = 'push_global_token'; -- +goose Down diff --git a/internal/db/migrator/goose/sqlite/202606140004_create_push_channels.sql b/internal/db/migrator/goose/sqlite/202606140004_create_push_channels.sql index 7a8dc932..b58ccb50 100644 --- a/internal/db/migrator/goose/sqlite/202606140004_create_push_channels.sql +++ b/internal/db/migrator/goose/sqlite/202606140004_create_push_channels.sql @@ -15,17 +15,5 @@ CREATE TABLE w_push_channels ( CREATE INDEX idx_w_push_channels_name ON w_push_channels(name); CREATE INDEX idx_w_push_channels_enabled ON w_push_channels(enabled); -INSERT OR IGNORE INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ( - 'push_global_token', - '', - 'system', - 0, - '系统全局推送鉴权令牌', - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -); - -- +goose Down -DELETE FROM w_system_configs WHERE key = 'push_global_token'; DROP TABLE IF EXISTS w_push_channels; diff --git a/internal/db/migrator/goose/sqlite/202606160001_remove_push_config.sql b/internal/db/migrator/goose/sqlite/202606160001_remove_push_config.sql index 16efd10e..d3214a00 100644 --- a/internal/db/migrator/goose/sqlite/202606160001_remove_push_config.sql +++ b/internal/db/migrator/goose/sqlite/202606160001_remove_push_config.sql @@ -1,5 +1,6 @@ -- +goose Up DELETE FROM w_system_configs WHERE key = 'push_config'; DELETE FROM w_push_events WHERE event_key = 'admin_login'; +DELETE FROM w_system_configs WHERE key = 'push_global_token'; -- +goose Down diff --git a/internal/db/migrator/migrator_test.go b/internal/db/migrator/migrator_test.go index 2fea6ef5..a355e2ec 100644 --- a/internal/db/migrator/migrator_test.go +++ b/internal/db/migrator/migrator_test.go @@ -17,7 +17,7 @@ import ( "gorm.io/gorm" ) -const expectedMigratedSystemConfigCount = 31 +const expectedMigratedSystemConfigCount = 30 func TestMigrateInitializesSQLiteDatabase(t *testing.T) { sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{