fix issues

This commit is contained in:
yanghao05
2023-02-07 11:45:23 +08:00
parent ed3e7e3bbf
commit 2d52491536
7 changed files with 48 additions and 23 deletions

View File

@@ -25,16 +25,16 @@ func NewMigrationSeeder() contracts.Seeder {
}
func (s *MigrationSeeder) Run(faker *gofakeit.Faker, db *gorm.DB) {
times := 10
for i := 0; i < times; i++ {
data := s.Generate(faker, i)
if i == 0 {
stmt := &gorm.Statement{DB: db}
_ = stmt.Parse(&data)
log.Printf("seeding %s for %d times", stmt.Schema.Table, times)
}
db.Create(&data)
}
// times := 10
// for i := 0; i < times; i++ {
// data := s.Generate(faker, i)
// if i == 0 {
// stmt := &gorm.Statement{DB: db}
// _ = stmt.Parse(&data)
// log.Printf("seeding %s for %d times", stmt.Schema.Table, times)
// }
// db.Create(&data)
// }
}
func (s *MigrationSeeder) Generate(faker *gofakeit.Faker, idx int) models.Migration {