initial commit
This commit is contained in:
commit
d40b69f1f9
58 changed files with 7919 additions and 0 deletions
36
backend/seed.go
Normal file
36
backend/seed.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"git.red-panda.pet/pandaware/house/backend/db"
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func seedDevData(sqlite *sql.DB) {
|
||||
ctx := context.Background()
|
||||
tx := db.New(sqlite)
|
||||
|
||||
id := uuid.Must(uuid.NewV7())
|
||||
|
||||
user, err := tx.CreateUser(ctx, db.CreateUserParams{
|
||||
ID: id.String(),
|
||||
Username: "red",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
password, err := bcrypt.GenerateFromPassword([]byte("password"), bcrypt.DefaultCost)
|
||||
|
||||
_, err = tx.UpdateUserPassword(ctx, db.UpdateUserPasswordParams{
|
||||
ID: user.ID,
|
||||
Password: password,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue