Documentation
¶
Overview ¶
Package seed runs explicitly registered data seeders through normal Foundry transactions. It never resets tables or treats repeated execution as a wipe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
Definition declares normal transactional domain work and its prerequisites. Run must use the supplied Tx. Idempotence is its own business contract; no history table silently suppresses later explicit invocations.
type ID ¶
type ID string
ID names a seeder once at registration. Use namespaces such as app.countries to distinguish application and plugin contributions.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry snapshots declarations and validates dependencies before execution. Shared callbacks must be concurrency-safe if applications invoke Run concurrently.
func New ¶
func New(definitions ...Definition) (*Registry, error)
New validates and snapshots seeder declarations and orders them by dependency. It rejects invalid, duplicate, missing or cyclic dependencies before execution.
func (*Registry) Run ¶
Run executes selected seeders and their dependencies once in deterministic order. Omit selected to run the whole registry. Selection errors fail before database I/O. Each seeder uses a separate transaction; earlier commits remain if a later seeder fails. The same seeder may run again in a later explicit call.
type Result ¶
type Result struct {
Committed []ID `json:"committed"`
StoppedAt *ID `json:"stopped_at,omitempty"`
}
Result lists seeders whose database transactions are confirmed committed. StoppedAt identifies the invocation that returned an error. It can also appear in Committed when only an after-commit callback failed. Inspect database error outcomes before retrying; the framework never retries arbitrary domain work.