diff --git a/cmd/gorm/main.go b/cmd/gorm/main.go index 9447fa8..004e777 100644 --- a/cmd/gorm/main.go +++ b/cmd/gorm/main.go @@ -6,6 +6,7 @@ import ( "legalgo-BE-go/config" "legalgo-BE-go/database" + categorydomain "legalgo-BE-go/internal/domain/category" subscribeplandomain "legalgo-BE-go/internal/domain/subscribe_plan" "github.com/google/uuid" @@ -36,9 +37,10 @@ func main() { log.Fatal("Migration failed: ", err) } - var temp subscribeplandomain.SubscribePlan + var tempSP subscribeplandomain.SubscribePlan + var tempCtg categorydomain.Category - if err := db.Where("code = ?", "basic").First(&temp).Error; err != nil { + if err := db.Where("code = ?", "basic").First(&tempSP).Error; err != nil { log.Print("seeding basic subscribe plan") db.Create(&subscribeplandomain.SubscribePlan{ ID: uuid.NewString(), @@ -50,5 +52,16 @@ func main() { }) } + if err := db.Where("code = ?", "spotlight").First(&tempCtg).Error; err != nil { + log.Print("seeding basic subscribe plan") + seq := 0 + db.Create(&categorydomain.Category{ + ID: uuid.NewString(), + Code: "spotlight", + Name: "Spotlight", + Sequence: &seq, + }) + } + log.Print("migrate success") }