first commit
This commit is contained in:
26
database/migrate.go
Normal file
26
database/migrate.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"gobeyhan/database/models"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Migrate runs AutoMigrate for all models used in the project.
|
||||
func Migrate(db *gorm.DB) error {
|
||||
// Order can matter due to foreign keys; migrate parents first
|
||||
return db.AutoMigrate(
|
||||
&models.User{},
|
||||
&models.SocialAccount{},
|
||||
&models.Role{},
|
||||
&models.Permission{},
|
||||
&models.Category{},
|
||||
&models.Tag{},
|
||||
&models.Post{},
|
||||
&models.CategoryView{},
|
||||
&models.Comment{},
|
||||
&models.CorsWhitelist{},
|
||||
&models.CorsBlacklist{},
|
||||
&models.RateLimitSetting{},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user