16 lines
396 B
SQL
16 lines
396 B
SQL
CREATE TABLE budgets (
|
|
id char(26) NOT NULL,
|
|
name text NOT NULL,
|
|
last_modification timestamp with time zone
|
|
);
|
|
|
|
-- 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; |