-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: make dummy populate function public
- Loading branch information
1 parent
e3fd5e5
commit 1679a80
Showing
2 changed files
with
72 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package dummy | ||
|
||
import ( | ||
"github.com/flanksource/duty/models" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func PopulateDBWithDummyModels(gormDB *gorm.DB) error { | ||
var err error | ||
createTime := DummyCreatedAt | ||
for _, c := range AllDummyPeople { | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyComponents { | ||
c.UpdatedAt = models.LocalTime(createTime) | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyComponentRelationships { | ||
c.UpdatedAt = createTime | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyConfigs { | ||
c.CreatedAt = createTime | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyConfigAnalysis { | ||
c.FirstObserved = &createTime | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyConfigComponentRelationships { | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyIncidents { | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyHypotheses { | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
for _, c := range AllDummyEvidences { | ||
err = gormDB.Create(&c).Error | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters