mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 10:16:37 +08:00
fix(migration): quote reserved authorization column
This commit is contained in:
@@ -49,6 +49,8 @@ sidebar: false
|
|||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
- 修复 Cloudflare DNS 指向功能在 PostgreSQL 初始化迁移时因 `authorization` 保留关键字导致启动失败的问题。
|
||||||
|
|
||||||
- 修复 IP 组自动抓取使用预设规则时未写入 `ttl` 字段的问题,避免配置 JSON 缺少封禁时长。
|
- 修复 IP 组自动抓取使用预设规则时未写入 `ttl` 字段的问题,避免配置 JSON 缺少封禁时长。
|
||||||
- 修复限流相关迁移中表名错误,确保升级脚本正确执行。
|
- 修复限流相关迁移中表名错误,确保升级脚本正确执行。
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS of_cf_connections (
|
|||||||
id BIGSERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
source VARCHAR(32) NOT NULL DEFAULT '',
|
source VARCHAR(32) NOT NULL DEFAULT '',
|
||||||
dns_account_id BIGINT,
|
dns_account_id BIGINT,
|
||||||
authorization TEXT NOT NULL DEFAULT '',
|
"authorization" TEXT NOT NULL DEFAULT '',
|
||||||
status VARCHAR(16) NOT NULL DEFAULT '',
|
status VARCHAR(16) NOT NULL DEFAULT '',
|
||||||
verified_at TIMESTAMPTZ,
|
verified_at TIMESTAMPTZ,
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package migrator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Rain-kl/Wavelet/internal/infra/config"
|
"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)
|
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") {
|
if sqliteDB.Migrator().HasTable("of_managed_domains") {
|
||||||
t.Error("Migrate() should drop of_managed_domains after phase-2 cleanup")
|
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) {
|
func TestMigrateClearsStaleSystemConfigCache(t *testing.T) {
|
||||||
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
||||||
DisableForeignKeyConstraintWhenMigrating: true,
|
DisableForeignKeyConstraintWhenMigrating: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user