fix(seed): skip seeding if database already contains markets
This commit is contained in:
@@ -65,6 +65,15 @@ func run() error {
|
||||
return fmt.Errorf("parse markets JSON: %w", err)
|
||||
}
|
||||
|
||||
var count int
|
||||
if err := pool.QueryRow(ctx, "SELECT count(*) FROM markets").Scan(&count); err != nil {
|
||||
return fmt.Errorf("check market count: %w", err)
|
||||
}
|
||||
if count > 0 {
|
||||
slog.Info("database already seeded, skipping", "existing", count)
|
||||
return nil
|
||||
}
|
||||
|
||||
slog.Info("seeding markets", "count", len(markets))
|
||||
|
||||
geoCache := make(map[string][2]float64)
|
||||
|
||||
Reference in New Issue
Block a user