Documentation
¶
Index ¶
- Constants
- Variables
- func AdoptDefaultOrganizationOwner(db *gorm.DB, adminID uint) error
- func ConnectPostgres(dsn string, logLevel gormlogger.LogLevel) (*gorm.DB, error)
- func EnsureInstallID(db *gorm.DB) (string, error)
- func NewDBLogger(level gormlogger.LogLevel) gormlogger.Interface
- func NewRedis(addr, password string, db int) (*redis.Client, error)
- func SchemaVersion(db *gorm.DB) string
- func SeedAdmin(db *gorm.DB, email, password string, validate func() error) (*models.User, error)
- func SeedDefaultOrganization(db *gorm.DB) (*models.Organization, error)
- func SeedPlans(db *gorm.DB) error
Constants ¶
const InstallIDKey = "install_id"
InstallIDKey is the settings key holding this deployment's stable Install ID.
Variables ¶
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
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 ¶
ConnectPostgres opens a GORM connection to PostgreSQL without running migrations.
func EnsureInstallID ¶
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 SchemaVersion ¶ added in v1.8.0
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 ¶
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.
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. |