database

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDBForTest added in v1.7.0

func CloseDBForTest() error

CloseDBForTest closes the pool and puts the package back to its pre-InitDB state. A test that installs a global DB has to call it: closing without clearing the handle would leave GetDB serving a live *gorm.DB wrapped around a dead pool, which fails as "sql: database is closed" from somewhere that never opened one.

Named for tests because it must not become a shutdown hook. Clearing the handle makes GetDB return nil, which no caller checks; APP.Stop runs cronJob.Stop first but that does not wait for in-flight jobs, and the scheduler is built without cron.Recover, so the first GetDB().Model(...) in a still-running job would panic the process instead of logging. Shutdown leaves the pool open and lets the process exit take it down.

func GetDB

func GetDB() *gorm.DB

func GetDb

func GetDb(exclude string) ([]byte, error)

func ImportDB

func ImportDB(file multipart.File) error

func InitDB

func InitDB(dbPath string) error

func IsNotFound

func IsNotFound(err error) bool

func IsSQLiteDB

func IsSQLiteDB(file io.Reader) (bool, error)

func OpenDB

func OpenDB(dbPath string) error

func SendSighup

func SendSighup() error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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