mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-25 00:14:42 -05:00
23 lines
330 B
Go
23 lines
330 B
Go
package database
|
|
|
|
import (
|
|
"gorm.io/driver/sqlite"
|
|
"gorm.io/gorm"
|
|
"sub2clash/model"
|
|
)
|
|
|
|
var DB *gorm.DB
|
|
|
|
func ConnectDB() error {
|
|
db, err := gorm.Open(sqlite.Open("sub2clash.db"), &gorm.Config{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
DB = db
|
|
err = db.AutoMigrate(&model.ShortLink{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|