Documentation
¶
Overview ¶
Package seeders builds database fixtures: the first-admin setup row and deterministic development users. It is standalone — SQL against the documented schema plus pkg/crypto for password hashing; no identity-module imports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasAnyUser ¶
HasAnyUser reports whether the accounts table is non-empty — the freshness gate for the setup flow.
func SetupAdmin ¶
SetupAdmin creates the first admin account with a hashed password. It fails when any user already exists — the setup flow is only valid on a fresh database. Input validation runs before the freshness gate so misconfiguration is reported precisely.
Types ¶
type AdminParams ¶
AdminParams carries the setup-admin fields.
type Executor ¶
type Executor interface {
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
Executor is the datastore.Executor surface the seeder needs. QueryRow returns pgx.Row directly — Go return-type invariance means a concrete pgx.Row cannot satisfy a custom Scanner iface.
type UserFactory ¶
type UserFactory struct {
// contains filtered or unexported fields
}
UserFactory creates deterministic development users (base_NNNN) with throwaway hashed passwords. Standalone: plain SQL plus pkg/crypto. Safe for concurrent use.
func NewUserFactory ¶
func NewUserFactory(db Executor, seed uint64) *UserFactory
NewUserFactory builds a factory over db. An explicit seed sets the starting suffix (mod 10000); zero selects a crypto-randomized start for ad-hoc runs.
func (*UserFactory) Create ¶
Create builds one user with the next sequential suffix, wrapping past 9999 back to 0000. Passwords are the username plus a fixed dev suffix — hashed, never stored in plaintext.
func (*UserFactory) CreateMany ¶
CreateMany builds count users sharing the same base name, returning their UUIDs in creation order.