update db
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Владимир Фёдоров 2024-11-21 01:02:15 +07:00
parent f4523de5a4
commit 2078e008f3
4 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS budgets (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
start_day INT NOT NULL,
created_at TIMESTAMP
);

View File

@ -3,7 +3,7 @@
CREATE TABLE IF NOT EXISTS categories (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
budget_id INT REFERENCES budgets(id),
budget_id INT REFERENCES budgets(id) ON DELETE CASCADE,
favorite BOOLEAN DEFAULT FALSE,
monthly_limit INT DEFAULT 0,
UNIQUE (budget_id, name),

View File

@ -5,6 +5,8 @@ CREATE TABLE IF NOT EXISTS positions (
name TEXT NOT NULL,
price INT NOT NULL,
amount FLOAT NOT NULL,
budget_id INT REFERENCES budgets(id) ON DELETE CASCADE,
category_id INT REFERENCES categories(id) ON DELETE RESTRICT,
created_at TIMESTAMP
);
-- +goose StatementEnd

View File

@ -0,0 +1,14 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS users_budgets (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id) ON DELETE CASCADE,
budget_id INT REFERENCES budgets(id) ON DELETE RESTRICT,
created_at TIMESTAMP
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS users_budgets;
-- +goose StatementEnd