Use goose for migrations
This commit is contained in:
14
postgres/queries/budgets.sql
Normal file
14
postgres/queries/budgets.sql
Normal file
@ -0,0 +1,14 @@
|
||||
-- name: CreateBudget :one
|
||||
INSERT INTO budgets
|
||||
(id, name, last_modification)
|
||||
VALUES ($1, $2, NOW())
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetBudgetsForUser :many
|
||||
SELECT budgets.* FROM budgets
|
||||
LEFT JOIN user_budgets ON budgets.id = user_budgets.budget_id
|
||||
WHERE user_budgets.user_id = $1;
|
||||
|
||||
-- name: GetBudget :one
|
||||
SELECT * FROM budgets
|
||||
WHERE id = $1;
|
5
postgres/queries/user_budgets.sql
Normal file
5
postgres/queries/user_budgets.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- name: LinkBudgetToUser :one
|
||||
INSERT INTO user_budgets
|
||||
(user_id, budget_id)
|
||||
VALUES ($1, $2)
|
||||
RETURNING *;
|
13
postgres/queries/users.sql
Normal file
13
postgres/queries/users.sql
Normal file
@ -0,0 +1,13 @@
|
||||
-- name: GetUserByUsername :one
|
||||
SELECT * FROM users
|
||||
WHERE email = $1;
|
||||
|
||||
-- name: GetUser :one
|
||||
SELECT * FROM users
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: CreateUser :one
|
||||
INSERT INTO users
|
||||
(id, email, name, password)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING *;
|
Reference in New Issue
Block a user