Skip to content

Commit

Permalink
Merge pull request #25 from ContainerMaintainers/seeds_fix
Browse files Browse the repository at this point in the history
Updated seeds.go to match models
  • Loading branch information
Cromski authored Feb 21, 2023
2 parents 0c4cd78 + e2c8f37 commit 3747c16
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions database/seeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ import (

type Seed struct {
SeedName string
Run func(*gorm.DB)
Run func(*gorm.DB)
}

func AllSeeds() []Seed {
return []Seed{
Seed{
SeedName: "CreateUser1",
Run: func(db *gorm.DB) {
CreateUser(db, 1, "user1", "[email protected]", "user1iscool")
CreateUser(db, "user1", "[email protected]", "user1iscool")
},
},
Seed{
SeedName: "CreateUser2",
Run: func(db *gorm.DB) {
CreateUser(db, 2, "user2", "[email protected]", "user2iscool")
CreateUser(db, "user2", "[email protected]", "user2iscool")
},
},
Seed{
SeedName: "CreateUser3",
Run: func(db *gorm.DB) {
CreateUser(db, 3, "user3", "[email protected]", "user3iscool")
CreateUser(db, "user3", "[email protected]", "user3iscool")
},
},
Seed{
SeedName: "CreateMessage1",
Run: func(db *gorm.DB) {
CreateMessage(db, 1, 1, "Hello World! From user1", 123456, false)
CreateMessage(db, 1, "Hello World! From user1", 123456, false)
},
},
Seed{
SeedName: "CreateMessage2",
Run: func(db *gorm.DB) {
CreateMessage(db, 2, 2, "Hello World! From user2", 123456, false)
CreateMessage(db, 2, "Hello World! From user2", 123456, false)
},
},
Seed{
SeedName: "CreateMessage3",
Run: func(db *gorm.DB) {
CreateMessage(db, 3, 3, "Hello World! From user3", 123456, false)
CreateMessage(db, 3, "Hello World! From user3", 123456, false)
},
},
Seed{
Expand All @@ -70,26 +70,23 @@ func AllSeeds() []Seed {
}
}


func CreateUser(db *gorm.DB, userID uint, username string, email string, pw string) {
func CreateUser(db *gorm.DB, username string, email string, pw string) {
db.Create(&entities.User{
User_ID: userID,
Username: username,
Email: email,
PW_Hash: pw})
Username: username,
Email: email,
PW_Hash: pw})
}

func CreateMessage(db *gorm.DB, message uint, author uint, text string, date uint, flagged bool) {
func CreateMessage(db *gorm.DB, author uint, text string, date uint, flagged bool) {
db.Create(&entities.Message{
Message_ID: message,
Author_ID: author,
Text: text,
Pub_Date: date,
Flagged: flagged})
Author_id: author,
Text: text,
Pub_Date: date,
Flagged: flagged})
}

func CreateFollower(db *gorm.DB, who uint, whom uint) {
db.Create(&entities.Follower{
Who_ID: who,
Whom_ID: whom})
Who_ID: who,
Whom_ID: whom})
}

0 comments on commit 3747c16

Please sign in to comment.