fix db
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-11-21 00:47:44 +07:00
parent 0d6bd456d6
commit f4523de5a4
12 changed files with 152 additions and 71 deletions
@@ -2,7 +2,9 @@
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username TEXT UNIQUE NOT NULL
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
created_at TIMESTAMP
);
-- +goose StatementEnd
@@ -0,0 +1,13 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS budgets (
id SERIAL PRIMARY KEY,
start_day INT NOT NULL,
created_at TIMESTAMP
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS budgets;
-- +goose StatementEnd
@@ -3,10 +3,11 @@
CREATE TABLE IF NOT EXISTS categories (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
user_id INT REFERENCES users(id),
budget_id INT REFERENCES budgets(id),
favorite BOOLEAN DEFAULT FALSE,
monthly_limit INT DEFAULT 0,
UNIQUE (user_id, name)
UNIQUE (budget_id, name),
created_at TIMESTAMP
);
-- +goose StatementEnd
@@ -0,0 +1,15 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS positions (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
price INT NOT NULL,
amount FLOAT NOT NULL,
created_at TIMESTAMP
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS positions;
-- +goose StatementEnd