revert: db transaction use, avoiding the pgx RETURNING issue while maintaining data consistency
This commit is contained in:
@@ -57,15 +57,10 @@ func HandleSeedCommand(cfg *config.Config, name string, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return withDatabase(cfg, func(db *gorm.DB) error {
|
return withDatabase(cfg, func(db *gorm.DB) error {
|
||||||
return db.Transaction(func(tx *gorm.DB) error {
|
userRepo := repositories.NewUserRepository(db)
|
||||||
userRepo := repositories.NewUserRepository(db).WithTx(tx)
|
postRepo := repositories.NewPostRepository(db)
|
||||||
postRepo := repositories.NewPostRepository(db).WithTx(tx)
|
voteRepo := repositories.NewVoteRepository(db)
|
||||||
voteRepo := repositories.NewVoteRepository(db).WithTx(tx)
|
return runSeedCommand(userRepo, postRepo, voteRepo, fs.Args())
|
||||||
if err := runSeedCommand(userRepo, postRepo, voteRepo, fs.Args()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user