feat: Add role parameter to user creation and SQL queries

- Update CreateUser SQL query to accept role parameter
- Regenerate SQLC code to include Role field in CreateUserParams
- Support for explicit role assignment during user registration
This commit is contained in:
2026-01-26 21:17:38 -05:00
parent 48b6796bcd
commit 5ca2e6a732
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -132,8 +132,8 @@ func (q *Queries) CreateEbookRating(ctx context.Context, arg CreateEbookRatingPa
}
const CreateUser = `-- name: CreateUser :one
INSERT INTO users (email, username, password_hash, first_name, last_name, theme)
VALUES ($1, $2, $3, $4, $5, $6)
INSERT INTO users (email, username, password_hash, first_name, last_name, theme, role)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, email, username, theme, first_name, last_name, role, created_at, updated_at
`
@@ -144,6 +144,7 @@ type CreateUserParams struct {
FirstName pgtype.Text `db:"first_name" json:"first_name"`
LastName pgtype.Text `db:"last_name" json:"last_name"`
Theme pgtype.Text `db:"theme" json:"theme"`
Role string `db:"role" json:"role"`
}
type CreateUserRow struct {
@@ -166,6 +167,7 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateU
arg.FirstName,
arg.LastName,
arg.Theme,
arg.Role,
)
var i CreateUserRow
err := row.Scan(
+2 -2
View File
@@ -1,6 +1,6 @@
-- name: CreateUser :one
INSERT INTO users (email, username, password_hash, first_name, last_name, theme)
VALUES ($1, $2, $3, $4, $5, $6)
INSERT INTO users (email, username, password_hash, first_name, last_name, theme, role)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, email, username, theme, first_name, last_name, role, created_at, updated_at;
-- name: GetUserByEmail :one