final project structure
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
var DB *gorm.DB
|
||||
@@ -37,7 +38,7 @@ func Connect() error {
|
||||
func Migrate() error {
|
||||
var err error
|
||||
err = DB.AutoMigrate(slices.Concat(
|
||||
models.LogModels, models.AssetModels, models.TaxonomyModels))
|
||||
log.Models, asset.Models, taxonomy.Models))
|
||||
if err != nil {
|
||||
return fmt.Errorf("auto migration failed: %w", err)
|
||||
}
|
||||
@@ -49,3 +50,7 @@ func Migrate() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Preload() *gorm.DB {
|
||||
return DB.Preload(clause.Associations)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user