Skip to content

feat(seeding): persistence first-boot seeders and database run-once seeders#73

Merged
tgiachi merged 8 commits into
developfrom
feature/seeders
Jul 7, 2026
Merged

feat(seeding): persistence first-boot seeders and database run-once seeders#73
tgiachi merged 8 commits into
developfrom
feature/seeders

Conversation

@tgiachi

@tgiachi tgiachi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Persistence seeders (IPersistenceSeeder, RegisterPersistenceSeeder<T>() / delegate form): run once, in registration order, on a FRESH save only (no snapshot, no journal - LastSequenceId == 0 after replay), between replay and the autosave loop. Seed writes go through the normal stores, so later boots never re-seed. Fail-fast on seeder exceptions; documented edges: no-op seeders re-run, an emptied-then-snapshotted save re-seeds, mid-sequence failure skips the tail (prefer a single seeder).
  • Database seeders (IDatabaseSeeder with Name, RegisterDatabaseSeeder<T>() / (name, delegate)): run once EVER per name, tracked in __squidstd_seed_history (synced independently of AutoMigrate); the history row is written only after success, so failed seeders retry at the next process start; duplicate names (ordinal) fail startup before any seeding.
  • Both stacks share the same registration mechanics (typed-list + lazy IReadOnlyList<TSeeder> materialization), interleave plugin-registered seeders naturally, and keep the services container-agnostic via optional ctor parameters.

Test plan

  • 12 new tests: persistence (fresh-run, double-boot no-rerun, prior-data skip, class-form DI, ordering, exception) and database (run-once + history, skip on second start, failed-seeder retry, duplicate names, class-form name, AutoMigrate-off)
  • Full suite green locally except the 41 machine-wide Testcontainers failures (host kernel pending reboot); CI validates the full suite
  • Release builds clean

tgiachi added 8 commits July 7, 2026 14:49
RegisterPersistenceSeeder (class or delegate form) records seeders that
run once, in registration order, after snapshot load and journal replay,
only when the save is brand new (no snapshot, no journal). Seed writes go
through the normal stores so later boots never re-seed; a seeder failure
aborts startup.
RegisterDatabaseSeeder (class or delegate form) records seeders executed
by DatabaseService at start, once ever per unique name: applied names are
tracked in the __squidstd_seed_history table (synced independently from
AutoMigrate), the history row is written only after a successful run so
failed seeders retry, and duplicate names fail startup before any seeding.
@tgiachi tgiachi merged commit a0eeb1f into develop Jul 7, 2026
3 checks passed
@tgiachi tgiachi deleted the feature/seeders branch July 7, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant