-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40c2ba4
commit 4f21c74
Showing
25 changed files
with
102 additions
and
247 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
29 changes: 29 additions & 0 deletions
29
internal/services/identity_service/identity/data/seeds/data_seeder.go
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,29 @@ | ||
package seeds | ||
|
||
import ( | ||
"github.com/meysamhadeli/shop-golang-microservices/internal/pkg/utils" | ||
"github.com/meysamhadeli/shop-golang-microservices/internal/services/identity_service/identity/models" | ||
"github.com/pkg/errors" | ||
uuid "github.com/satori/go.uuid" | ||
"gorm.io/gorm" | ||
"time" | ||
) | ||
|
||
func DataSeeder(gorm *gorm.DB) error { | ||
return seedUser(gorm) | ||
} | ||
|
||
func seedUser(gorm *gorm.DB) error { | ||
if (gorm.Find(&models.User{}).RowsAffected <= 0) { | ||
pass, err := utils.HashPassword("Admin@12345") | ||
if err != nil { | ||
return err | ||
} | ||
user := &models.User{UserId: uuid.NewV4(), UserName: "admin_user", FirstName: "admin", LastName: "admin", CreatedAt: time.Now(), Email: "[email protected]", Password: pass} | ||
|
||
if err := gorm.Create(user).Error; err != nil { | ||
return errors.Wrap(err, "error in the inserting user into the database.") | ||
} | ||
} | ||
return nil | ||
} |
1 change: 0 additions & 1 deletion
1
internal/services/identity_service/identity/data/seeds/user_postgres_seed.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.