Use goose for migrations
This commit is contained in:
@ -5,7 +5,6 @@ package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createUser = `-- name: CreateUser :one
|
||||
@ -16,14 +15,14 @@ RETURNING id, email, name, password
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
ID sql.NullString
|
||||
Email sql.NullString
|
||||
Name sql.NullString
|
||||
Password sql.NullString
|
||||
ID string
|
||||
Email string
|
||||
Name string
|
||||
Password string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, createUser,
|
||||
row := q.db.QueryRowContext(ctx, createUser,
|
||||
arg.ID,
|
||||
arg.Email,
|
||||
arg.Name,
|
||||
@ -44,8 +43,8 @@ SELECT id, email, name, password FROM users
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUser(ctx context.Context, id sql.NullString) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUser, id)
|
||||
func (q *Queries) GetUser(ctx context.Context, id string) (User, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUser, id)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
@ -61,8 +60,8 @@ SELECT id, email, name, password FROM users
|
||||
WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByUsername(ctx context.Context, email sql.NullString) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUserByUsername, email)
|
||||
func (q *Queries) GetUserByUsername(ctx context.Context, email string) (User, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserByUsername, email)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
|
Reference in New Issue
Block a user