geo ip_info 테이블 생성 조건 변경
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -132,6 +133,21 @@ func verifyCounts(ctx context.Context, cfg SyncConfig, dumper *Dumper, conn *pgx
|
||||
}
|
||||
|
||||
func ensureIPGeoInfo(ctx context.Context, cfg SyncConfig, conn *pgx.Conn) error {
|
||||
exists, err := ipGeoInfoExists(ctx, conn, cfg.Schema)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
seedPath := filepath.Join("/initial_data", "ip_geoinfo_seed_20251208.sql")
|
||||
if _, err := os.Stat(seedPath); err == nil {
|
||||
if err := ExecuteSQLFile(ctx, conn, seedPath); err != nil {
|
||||
return fmt.Errorf("execute seed sql: %w", err)
|
||||
}
|
||||
exists = true
|
||||
}
|
||||
}
|
||||
|
||||
if err := EnsureIPGeoInfoTable(ctx, conn, cfg.Schema); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -159,6 +175,9 @@ func ensureIPGeoInfo(ctx context.Context, cfg SyncConfig, conn *pgx.Conn) error
|
||||
return fmt.Errorf("generate ip_geoinfo sql: %w", err)
|
||||
}
|
||||
if count == 0 {
|
||||
if !exists {
|
||||
return fmt.Errorf("seeded ip_geoinfo but no new IPs found for update")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := ExecuteSQLFile(ctx, conn, sqlPath); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user