bootstrap

package
v0.0.0-...-f17429d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBannerFile

func EnsureBannerFile(filename, defaultText string) error

EnsureBannerFile ensures banner.txt exists, generates it if it doesn't

func GenerateBannerWithDoomFont

func GenerateBannerWithDoomFont(text, filename string) error

GenerateBannerWithDoomFont generates ASCII art banner using Doom font and saves to file

func LogConfigInfo

func LogConfigInfo()

LogConfigInfo Print global configuration information

func PrintBannerFromFile

func PrintBannerFromFile(filename string, defaultText string) error

PrintBannerFromFile Read file and print, auto-generate if file doesn't exist

func RunInitSQL

func RunInitSQL(db *gorm.DB, sqlFilePath string) error

RunInitSQL executes SQL statements from a local .sql file segment by segment (split by semicolon ;), idempotent scripts should use IF NOT EXISTS in SQL for protection

func RunMigrations

func RunMigrations(db *gorm.DB, entities []any) error

RunMigrations executes GORM AutoMigrate for the given entities.

func SetupDatabase

func SetupDatabase(logWriter io.Writer, opts *Options) (*gorm.DB, error)

SetupDatabase unified entry: connect database -> run initialization SQL -> migrate entities -> (non-production) write default configuration

Types

type Options

type Options struct {
	// InitSQLPath points to a .sql script file (optional); skip if empty
	InitSQLPath string
	// AutoMigrate whether to execute entity migration (default true)
	AutoMigrate bool
	// SeedNonProd whether to write default configuration in non-production environments (default true)
	SeedNonProd bool
	// MigrateModels returns entities passed to GORM AutoMigrate when AutoMigrate is true.
	// Required for entity migration when AutoMigrate is true (each binary supplies its own list).
	MigrateModels func() []any
}

Options controls database initialization behavior

type SeedService

type SeedService struct {
	// contains filtered or unexported fields
}

func (*SeedService) SeedAll

func (s *SeedService) SeedAll() error

Jump to

Keyboard shortcuts

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