mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-24 07:12:42 +00:00
invalid db.go
This commit is contained in:
parent
1aad1ef359
commit
d457c5a9d0
1 changed files with 5 additions and 8 deletions
|
|
@ -121,10 +121,9 @@ func isTableEmpty(tableName string) (bool, error) {
|
||||||
// InitDB sets up the database connection, migrates models, and runs seeders.
|
// InitDB sets up the database connection, migrates models, and runs seeders.
|
||||||
func InitDB(dbPath string) error {
|
func InitDB(dbPath string) error {
|
||||||
dir := path.Dir(dbPath)
|
dir := path.Dir(dbPath)
|
||||||
err := os.MkdirAll(dir, fs.ModePerm)
|
if err := os.MkdirAll(dir, fs.ModePerm); err != nil { return err }
|
||||||
if err != nil {
|
// ...
|
||||||
return err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var gormLogger logger.Interface
|
var gormLogger logger.Interface
|
||||||
|
|
||||||
|
|
@ -170,9 +169,7 @@ func CloseDB() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDB returns the global GORM database instance.
|
// GetDB returns the global GORM database instance.
|
||||||
func GetDB() *gorm.DB {
|
func GetDB() *gorm.DB { return db }
|
||||||
return db
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsNotFound checks if the given error is a GORM record not found error.
|
// IsNotFound checks if the given error is a GORM record not found error.
|
||||||
func IsNotFound(err error) bool {
|
func IsNotFound(err error) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue