storage

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const InstallIDKey = "install_id"

InstallIDKey is the settings key holding this deployment's stable Install ID.

Variables

View Source
var ErrAdminSeedInvalid = errors.New("cannot seed the platform admin")

ErrAdminSeedInvalid wraps credentials that cannot seed the first platform admin. Boot must stop on it: an install left without an admin would make whoever registers first the platform admin.

Functions

func AdoptDefaultOrganizationOwner added in v1.10.4

func AdoptDefaultOrganizationOwner(db *gorm.DB, adminID uint) error

AdoptDefaultOrganizationOwner makes the platform admin the owner of the default organization when it has none. The default organization is seeded before any user exists, so it cannot take an owner at creation the way a later one does — and the first platform admin is a deterministic answer, unlike "whoever signs in first". Idempotent: an organization that already has an owner keeps it.

func ConnectPostgres

func ConnectPostgres(dsn string, logLevel gormlogger.LogLevel) (*gorm.DB, error)

ConnectPostgres opens a GORM connection to PostgreSQL without running migrations.

func EnsureInstallID

func EnsureInstallID(db *gorm.DB) (string, error)

EnsureInstallID returns this instance's stable Install ID, generating and persisting one on first call. It is immutable for the life of the deployment — a customer quotes it when buying a license — so it must survive restarts. Race-safe across concurrent boots via FirstOrCreate.

func NewDBLogger added in v1.10.18

func NewDBLogger(level gormlogger.LogLevel) gormlogger.Interface

NewDBLogger returns a GORM logger at the given level. It never logs bound values, which can carry passwords and secrets, and never reports "record not found", which Miabi uses as control flow.

func NewRedis

func NewRedis(addr, password string, db int) (*redis.Client, error)

NewRedis creates and verifies a Redis client on the given database index.

func SchemaVersion added in v1.8.0

func SchemaVersion(db *gorm.DB) string

SchemaVersion returns the version of the most recently applied upgrade step, or "" when none has run. A recovery point records it so restore can refuse to load a dump into an older binary than produced it — a downgrade restore corrupts silently, where a refusal costs nothing.

func SeedAdmin

func SeedAdmin(db *gorm.DB, email, password string, validate func() error) (*models.User, error)

SeedAdmin ensures a platform admin exists: returns the existing admin if one is already present, otherwise creates one from the configured credentials. Idempotent — safe to run on every boot. (Mirrors the Posta admin seeder.)

validate checks the credentials and runs only when an admin is about to be created.

func SeedDefaultOrganization

func SeedDefaultOrganization(db *gorm.DB) (*models.Organization, error)

SeedDefaultOrganization ensures exactly one default organization exists — the realm new workspaces and SSO providers attach to. Idempotent; safe on every boot. Returns the default org.

func SeedPlans

func SeedPlans(db *gorm.DB) error

SeedPlans creates the built-in plan catalog on first boot if no plans exist. Idempotent — a no-op once any plan is present (so admin edits are preserved). Limits use -1 for unlimited, 0 for none.

Types

This section is empty.

Directories

Path Synopsis
Package blob is a minimal S3/MinIO object client for the few places Miabi must touch an object store directly from Go: a bundle's control objects and bucket listings, and `miabi restore`, which reads a sealed envelope on a bare host before any platform exists.
Package blob is a minimal S3/MinIO object client for the few places Miabi must touch an object store directly from Go: a bundle's control objects and bucket listings, and `miabi restore`, which reads a sealed envelope on a bare host before any platform exists.
Package logbackfill migrates pre-existing large log rows out of Postgres into the shared log store.
Package logbackfill migrates pre-existing large log rows out of Postgres into the shared log store.
upgrade
Package upgrade runs ordered, versioned data-upgrade steps.
Package upgrade runs ordered, versioned data-upgrade steps.

Jump to

Keyboard shortcuts

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