fix: add seeding spotlight category
This commit is contained in:
parent
7b529ba46e
commit
efab193793
@ -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")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user