diff --git a/backend/cmd/seed/main.go b/backend/cmd/seed/main.go index 2c8d76a..25cf379 100644 --- a/backend/cmd/seed/main.go +++ b/backend/cmd/seed/main.go @@ -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)