Documentation
¶
Index ¶
- Variables
- func Filesystems() []fs.FS
- func ProfileFilesystems(profile MigrationProfile, opts ...ProfileOption) ([]fs.FS, error)
- func Register(fsys fs.FS)
- func RegisterProfile(profile MigrationProfile, opts ...ProfileOption) error
- func ValidateAuthSchema(ctx context.Context, db *sql.DB, dialect string, opts ...AuthSchemaOption) error
- type AuthSchemaCheck
- type AuthSchemaOption
- type AuthSchemaValidationError
- type MigrationProfile
- type ProfileOption
- type ProfileSource
Constants ¶
This section is empty.
Variables ¶
var DefaultAuthSchemaChecks = []AuthSchemaCheck{ { Table: "users", Columns: []string{ "id", "email", "username", "status", }, }, { Table: "password_reset", Columns: []string{ "id", "user_id", "email", "status", "jti", "issued_at", "expires_at", "used_at", "scope_tenant_id", "scope_org_id", }, }, }
DefaultAuthSchemaChecks captures the minimal columns go-users expects on auth tables.
Functions ¶
func Filesystems ¶
Filesystems returns a copy of all registered migration filesystems.
func ProfileFilesystems ¶ added in v0.17.0
func ProfileFilesystems(profile MigrationProfile, opts ...ProfileOption) ([]fs.FS, error)
ProfileFilesystems returns only the filesystems for a profile in registration order.
func Register ¶
Register records a filesystem that contains go-users migrations. Callers can then feed all registered filesystems into go-persistence-bun (or any other runner) via Filesystems().
func RegisterProfile ¶ added in v0.17.0
func RegisterProfile(profile MigrationProfile, opts ...ProfileOption) error
RegisterProfile resolves a profile and records its filesystems in registry order.
func ValidateAuthSchema ¶ added in v0.12.0
func ValidateAuthSchema(ctx context.Context, db *sql.DB, dialect string, opts ...AuthSchemaOption) error
ValidateAuthSchema ensures auth-owned tables expose columns go-users relies on.
Types ¶
type AuthSchemaCheck ¶ added in v0.12.0
AuthSchemaCheck describes a table/column requirement for auth-backed schemas.
type AuthSchemaOption ¶ added in v0.12.0
type AuthSchemaOption func(*authSchemaConfig)
AuthSchemaOption customizes auth schema validation.
func WithAuthSchemaChecks ¶ added in v0.12.0
func WithAuthSchemaChecks(checks []AuthSchemaCheck) AuthSchemaOption
WithAuthSchemaChecks replaces the default checks with a custom list.
type AuthSchemaValidationError ¶ added in v0.12.0
AuthSchemaValidationError summarizes missing auth tables/columns.
func (*AuthSchemaValidationError) Error ¶ added in v0.12.0
func (e *AuthSchemaValidationError) Error() string
type MigrationProfile ¶ added in v0.17.0
type MigrationProfile string
MigrationProfile defines which go-users migration tracks should be registered.
const ( // ProfileCombinedWithAuth registers core-only migrations and is intended for // installs where go-auth migrations are already registered. ProfileCombinedWithAuth MigrationProfile = "combined-with-auth" // ProfileStandalone registers auth bootstrap + optional auth extras + core. ProfileStandalone MigrationProfile = "standalone" )
type ProfileOption ¶ added in v0.17.0
type ProfileOption func(*profileOptions)
ProfileOption customizes ProfileSources.
func WithProfileAuthExtras ¶ added in v0.17.0
func WithProfileAuthExtras(enabled bool) ProfileOption
WithProfileAuthExtras toggles auth_extras for standalone profiles. Combined-with-auth profiles reject this option when set to true.
func WithProfileSourceLabels ¶ added in v0.17.0
func WithProfileSourceLabels(coreLabel, authLabel, authExtrasLabel string) ProfileOption
WithProfileSourceLabels overrides source labels used for registration.
func WithProfileValidationTargets ¶ added in v0.17.0
func WithProfileValidationTargets(targets ...string) ProfileOption
WithProfileValidationTargets overrides dialect validation targets.
type ProfileSource ¶ added in v0.17.0
type ProfileSource struct {
Name string
SourceLabel string
Subdir string
Filesystem fs.FS
ValidationTargets []string
}
ProfileSource describes a migration source to register through go-persistence-bun.
func ProfileSources ¶ added in v0.17.0
func ProfileSources(profile MigrationProfile, opts ...ProfileOption) ([]ProfileSource, error)
ProfileSources returns ordered migration sources for the selected profile.
Supported profiles:
- ProfileCombinedWithAuth: core migrations only
- ProfileStandalone: auth bootstrap + optional auth extras + core