ReviewOS

stacks/wildloop

Add a DatabaseSeeder orchestrator (plain 'buddy seed' is a no-op)

#975
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

database/seeders/ has per-model seeders but no orchestrator, so buddy seed (no --class) does nothing. Seeding the full world requires running each class, and game data (territories from the engine) isn't seeded at all by the scaffolded seeders — that lives in the ad-hoc scripts/seed-game-world.ts.

Acceptance

  • DatabaseSeeder that runs the model seeders in FK order + seeds a real game world (users/activities/engine-produced territories).
  • buddy seed populates a coherent demo.
8 days ago

Done — and verified by running it, on two throwaway databases, because the premise here needed testing rather than reading.

buddy seed is no longer a no-op. The framework gained runApplicationSeeders() (@stacksjs/database), which walks database/seeders/, loads every default-exported Seeder, sorts by static order and runs them. buddy seed drives it, with --only-seeders, --except-seeders, --tag, --skip-application-seeders and --skip-models on top.

The orchestration this issue asked for is the order metadata, and all 22 seeders carry it. Captured from a real --verbose run, this is the order they execute in:

UserSeeder → AdminSeeder → TrailSeeder → TrailDuplicateCleanupSeeder → AvatarSeeder
→ ClubSeeder → ActivitySeeder → EventSeeder → TerritorySeeder → TerritoryHistorySeeder
→ TerritoryStatsSeeder → ReviewSeeder → AchievementSeeder → FollowSeeder → KudosSeeder
→ ActivityCommentSeeder → SavedTrailSeeder → ChallengeSeeder → CustomRouteSeeder
→ RouteEffortSeeder → UserNotificationSeeder → CounterSeeder

Users before everything, trails before reviews, activities before kudos and comments, counters last. That is FK order, not the alphabetical order the directory would otherwise give — UserSeeder pulls itself to the front with static override order = -100, and a comment there records that path order once put ClubSeeder first and left it with nothing to attach to.

It produces a coherent demo. Fresh database, buddy migrate then plain buddy seed:

users / user_stats8 / 8
trails25
activities23
kudos / comments80 / 10
reviews31
territories (8 active, 9 with a bbox)9
territory_histories13
clubs / challenges / achievements9 / 5 / 20
follows / saved_trails17 / 16

And it hangs together — every referential check came back zero:

activities without a user      0
kudos without an activity      0
comments without an activity   0
reviews without a trail        0
follows without a follower     0

Both acceptance items are met: a seeder set that runs in FK order, and buddy seed populating a coherent world including territories with bounding boxes and a history behind them. scripts/seed-game-world.ts is no longer the only way to get game data — TerritorySeeder, TerritoryHistorySeeder and TerritoryStatsSeeder do it as part of the ordinary run.

Sign in to comment on this issue.