phoenix/database/db.go
Ivan R. 6d25c4e8af
feat!: migrate to net/http
With the release of Go 1.22, the standard library now has
all the necessary functions that allow us to abandon Gin.

I hope this rewrite will lower the entry barrier for new developers.
As a nice bonus, the size of the program has decreased from 20 to 15.4 MB.

To solve issue #81, request logging has been improved.
Now all errors are displayed in the logs.
2024-03-25 15:52:18 +05:00

23 lines
385 B
Go

package database
import (
"github.com/ordinary-dev/phoenix/config"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
var DB *gorm.DB
func EstablishDatabaseConnection(cfg *config.Config) error {
var err error
DB, err = gorm.Open(sqlite.Open(cfg.DBPath), &gorm.Config{})
if err != nil {
return err
}
// Migrate the schema
DB.AutoMigrate(&Admin{}, &Group{}, &Link{})
return nil
}