seeders

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package seeders creates the rows a fresh project cannot boot usefully without.

The admin seeder exists because togo ships no way to get a first admin: there is no `togo make:admin`, no ADMIN_EMAIL convention, and no first-user rule anywhere in togo-framework/auth. The documented alternative, the auth-dev plugin, sets roles on the in-memory Identity only — the users row keeps an empty roles column — and it refuses to run at APP_ENV=production. So a real deployment has no path to an administrator at all.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPassword = errors.New(
	"no admin password supplied: pipe it on stdin (`… | togo-builder seed admin`) " +
		"or set BUILDER_ADMIN_PASSWORD for non-interactive use")

ErrNoPassword is returned when no password was supplied.

There is deliberately no default and no generated-and-printed password. A well-known default admin password is the single most reliable way to ship a compromised deployment, and printing a generated one puts a live credential into CI logs and shell history.

Functions

This section is empty.

Types

type AdminOptions

type AdminOptions struct {
	Email string
	// Password is the plaintext to hash. Never logged, never defaulted.
	Password string
	// Force rewrites the password and role of an existing row. Off by default
	// so that re-running a scaffold cannot silently reset a live account.
	Force bool
}

AdminOptions configures the seed.

type AdminResult

type AdminResult struct {
	Email    string
	Created  bool
	Updated  bool
	Skipped  bool
	UserID   string
	GrantedN int
}

AdminResult reports what happened, for the CLI to print.

func SeedAdmin

func SeedAdmin(ctx context.Context, db *sql.DB, opts AdminOptions) (AdminResult, error)

SeedAdmin idempotently ensures an administrator exists.

Idempotency is by email. Re-running is safe: without Force an existing row is left exactly as it is, including its password, so `togo-builder new` can be re-run over a project without disturbing accounts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL