mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 08:36:37 +08:00
fix(migration): quote reserved authorization column
This commit is contained in:
+1
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user