migrations

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func Filesystems() []fs.FS

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

func Register(fsys fs.FS)

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

type AuthSchemaCheck struct {
	Table   string
	Columns []string
}

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

type AuthSchemaValidationError struct {
	MissingTables  []string
	MissingColumns map[string][]string
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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