Documentation
¶
Index ¶
- func EnsureBannerFile(filename, defaultText string) error
- func GenerateBannerWithDoomFont(text, filename string) error
- func LogConfigInfo()
- func PrintBannerFromFile(filename string, defaultText string) error
- func RunInitSQL(db *gorm.DB, sqlFilePath string) error
- func RunMigrations(db *gorm.DB, entities []any) error
- func SetupDatabase(logWriter io.Writer, opts *Options) (*gorm.DB, error)
- type Options
- type SeedService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureBannerFile ¶
EnsureBannerFile ensures banner.txt exists, generates it if it doesn't
func GenerateBannerWithDoomFont ¶
GenerateBannerWithDoomFont generates ASCII art banner using Doom font and saves to file
func PrintBannerFromFile ¶
PrintBannerFromFile Read file and print, auto-generate if file doesn't exist
func RunInitSQL ¶
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 ¶
RunMigrations executes GORM AutoMigrate for the given entities.
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
Click to show internal directories.
Click to hide internal directories.