CLI Reference

add seeder

Add a seeder to the project's central seeds/ package, registered automatically.
go tool gpsystem add seeder <name>

Writes a seeder stub into the project's central seeds/ package and registers it in seeds/register.go. The seeder returns a seed.Seeder: a name, an optional Guard (decides whether it runs at all), and the Run body. Details and patterns: Seeders.

go tool gpsystem add seeder adminUser

What it generates

seeds/admin_user.go
func adminUser(deps Deps) seed.Seeder {
    return seed.Seeder{
        Name: "admin_user",
        Run: func(ctx context.Context) error {
            return nil
        },
    }
}
seeds/register.go
func Register(reg *seed.Registry, deps Deps) {
    reg.Add(adminUser(deps))
    // gpsystem:seeds
}

Deps (in seeds/register.go, present in every project since new project) carries a *pg.DB or *bun.DB field per the project's --db choice, plus a dbx.Transactor. The command expects the seeds/register.go every project has had since new project; if it's missing (a project older than this feature), it fails and says so.

Running it

go run ./cmd/migrate up --seed   # migrate, then seed
go run ./cmd/migrate seed        # seed only
add seeder only writes and registers the stub: the business logic (what to load, under what condition) is yours to write into the generated file. See Seeders for the Guard, ErrSkip and multi-tenant WithTenants patterns.
Copyright © 2026