fix(migration): quote reserved authorization column

This commit is contained in:
ryan
2026-08-04 12:49:58 +08:00
parent 3edcdb9e9f
commit ea7658815a
3 changed files with 17 additions and 1 deletions
+2
View File
@@ -49,6 +49,8 @@ sidebar: false
### 修复
- 修复 Cloudflare DNS 指向功能在 PostgreSQL 初始化迁移时因 `authorization` 保留关键字导致启动失败的问题。
- 修复 IP 组自动抓取使用预设规则时未写入 `ttl` 字段的问题,避免配置 JSON 缺少封禁时长。
- 修复限流相关迁移中表名错误,确保升级脚本正确执行。
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS of_cf_connections (
id BIGSERIAL PRIMARY KEY,
source VARCHAR(32) NOT NULL DEFAULT '',
dns_account_id BIGINT,
authorization TEXT NOT NULL DEFAULT '',
"authorization" TEXT NOT NULL DEFAULT '',
status VARCHAR(16) NOT NULL DEFAULT '',
verified_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -5,6 +5,7 @@ package migrator
import (
"context"
"strings"
"testing"
"github.com/Rain-kl/Wavelet/internal/infra/config"
@@ -93,6 +94,9 @@ func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
t.Errorf("Migrate() did not create %s", table)
}
}
if !sqliteDB.Migrator().HasColumn("of_cf_connections", "authorization") {
t.Error("Migrate() did not create of_cf_connections.authorization")
}
if sqliteDB.Migrator().HasTable("of_managed_domains") {
t.Error("Migrate() should drop of_managed_domains after phase-2 cleanup")
}
@@ -140,6 +144,16 @@ func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
}
}
func TestCloudflarePointingPostgresMigrationQuotesAuthorizationColumn(t *testing.T) {
content, err := migrationFS.ReadFile("goose/postgres/202608040001_create_cloudflare_pointing.sql")
if err != nil {
t.Fatalf("read Cloudflare pointing migration: %v", err)
}
if !strings.Contains(string(content), `"authorization" TEXT NOT NULL DEFAULT ''`) {
t.Error("Cloudflare pointing PostgreSQL migration must quote reserved column authorization")
}
}
func TestMigrateClearsStaleSystemConfigCache(t *testing.T) {
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,