为已执行旧版 0062 的环境补充不可变修复迁移,恢复 Stream 状态字段和 Verification challenge 表;同时为 timestamptz 参数增加显式类型,避免 pgx 在真实 PostgreSQL 中推断冲突。\n\n验证:pnpm test;pnpm lint;pnpm build;真实 PostgreSQL 集成测试通过。
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSecurityEventIdempotencyRepairMigrationExists(t *testing.T) {
|
|
payload, err := os.ReadFile("../../migrations/0064_security_event_connection_idempotency_repair.sql")
|
|
if err != nil {
|
|
t.Fatalf("read repair migration: %v", err)
|
|
}
|
|
sql := string(payload)
|
|
for _, statement := range []string{
|
|
"CREATE TABLE IF NOT EXISTS gateway_security_event_connection_idempotency",
|
|
"CREATE INDEX IF NOT EXISTS idx_gateway_security_event_connection_idempotency_created",
|
|
} {
|
|
if !strings.Contains(sql, statement) {
|
|
t.Fatalf("repair migration is missing %q", statement)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSecurityEventVerificationStateRepairMigrationExists(t *testing.T) {
|
|
payload, err := os.ReadFile("../../migrations/0065_security_event_verification_state_repair.sql")
|
|
if err != nil {
|
|
t.Fatalf("read verification state repair migration: %v", err)
|
|
}
|
|
sql := string(payload)
|
|
for _, statement := range []string{
|
|
"ADD COLUMN IF NOT EXISTS stream_status",
|
|
"ADD COLUMN IF NOT EXISTS created_at",
|
|
"CREATE TABLE IF NOT EXISTS gateway_security_event_verification_challenges",
|
|
"CREATE INDEX IF NOT EXISTS idx_gateway_security_event_challenges_expiry",
|
|
} {
|
|
if !strings.Contains(sql, statement) {
|
|
t.Fatalf("verification state repair migration is missing %q", statement)
|
|
}
|
|
}
|
|
}
|