mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 22:26:38 +08:00
00593742c3
Add a separate ClickHouse OLAP pipeline with goose/clickhouse DDL as the sole schema source, model/analytics for ORM mapping, and repository/analytics for reads (ChDB/GORM) and batch writes (ChConn). Refactor risk_control and admin/logs to use the repository layer instead of inline SQL. Remove the manual support-files DDL and document the workflow in database-migration skill.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package migrator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/Rain-kl/Wavelet/internal/config"
|
|
"github.com/pressly/goose/v3"
|
|
)
|
|
|
|
func TestClickHouseMigrationFilesEmbedded(t *testing.T) {
|
|
entries, err := clickhouseMigrationFS.ReadDir(clickhouseMigrationDir)
|
|
if err != nil {
|
|
t.Fatalf("ReadDir(%q) error = %v", clickhouseMigrationDir, err)
|
|
}
|
|
if len(entries) == 0 {
|
|
t.Fatal("expected embedded ClickHouse migrations, got none")
|
|
}
|
|
|
|
found := false
|
|
for _, entry := range entries {
|
|
if entry.IsDir() {
|
|
continue
|
|
}
|
|
if entry.Name() == "202606190001_create_user_access_logs.sql" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("expected 202606190001_create_user_access_logs.sql in embedded migrations")
|
|
}
|
|
}
|
|
|
|
func TestClickHouseGooseDialect(t *testing.T) {
|
|
if err := goose.SetDialect("clickhouse"); err != nil {
|
|
t.Fatalf("SetDialect(clickhouse) error = %v", err)
|
|
}
|
|
}
|
|
|
|
func TestMigrateClickHouseSkipsWhenDisabled(t *testing.T) {
|
|
previousEnabled := config.Config.ClickHouse.Enabled
|
|
config.Config.ClickHouse.Enabled = false
|
|
t.Cleanup(func() {
|
|
config.Config.ClickHouse.Enabled = previousEnabled
|
|
})
|
|
|
|
MigrateClickHouse()
|
|
} |