Seeds
Database seeds populate tables with initial or test data. GoFrame executes them through the CLI and tracks which seeds already ran.
Seeds live under db/seeds
and are listed in db/seeds.go
.
Generate one with:
go run cmd/cli/main.go generate seed <name> [--sql]
Use --sql
to create a SQL seed instead of Go code.
Run all unapplied seeds:
go run cmd/cli/main.go db seeds up
Applied seeds can be listed using:
go run cmd/cli/main.go db seeds show
Each seed implements the seed.Seed
interface and may be grouped in a single transaction.
Last updated on