azote-backend/migrate/migration.go

27 lines
422 B
Go
Raw Normal View History

2024-01-16 00:36:49 +01:00
package main
import (
"azote-backend/initializers"
"azote-backend/models"
"log"
)
func init() {
initializers.LoadEnv()
initializers.ConnectToDB()
}
func main() {
log.Println("Migrating models to db...")
err := initializers.DB.AutoMigrate(
&models.User{},
&models.File{},
&models.Post{})
if err != nil {
log.Fatalf("Automatic migration has failed : %v", err)
}
log.Println("Migration successful.")
}