Fix 0001_enable-uuid-ossp and reorder
This commit is contained in:
parent
e2d22a1080
commit
1437fc7b8d
@ -73,10 +73,10 @@ func (h *Handler) Serve() {
|
||||
user := authenticated.Group("/user")
|
||||
user.GET("/logout", logout)
|
||||
|
||||
budget := api.Group("/budget")
|
||||
budget := authenticated.Group("/budget")
|
||||
budget.POST("/new", h.newBudget)
|
||||
|
||||
transaction := api.Group("/transaction")
|
||||
transaction := authenticated.Group("/transaction")
|
||||
transaction.POST("/new", h.newTransaction)
|
||||
transaction.POST("/import/ynab", h.importYNAB)
|
||||
|
||||
|
5
postgres/schema/0001_enable-uuid-ossp.sql
Normal file
5
postgres/schema/0001_enable-uuid-ossp.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
-- +goose Down
|
||||
DROP EXTENSION "uuid-ossp";
|
@ -1,6 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
CREATE TABLE budgets (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
@ -35,6 +33,20 @@ CREATE TABLE payees (
|
||||
);
|
||||
ALTER TABLE "payees" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
|
||||
|
||||
CREATE TABLE category_groups (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
budget_id uuid NOT NULL,
|
||||
name varchar(50) NOT NULL
|
||||
);
|
||||
ALTER TABLE "category_groups" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
|
||||
|
||||
CREATE TABLE categories (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
category_group_id uuid NOT NULL,
|
||||
name varchar(50) NOT NULL
|
||||
);
|
||||
ALTER TABLE "categories" ADD FOREIGN KEY ("category_group_id") REFERENCES "category_groups" ("id");
|
||||
|
||||
CREATE TABLE transactions (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
date date NOT NULL,
|
||||
@ -48,26 +60,12 @@ ALTER TABLE "transactions" ADD FOREIGN KEY ("account_id") REFERENCES "accounts"
|
||||
ALTER TABLE "transactions" ADD FOREIGN KEY ("payee_id") REFERENCES "payees" ("id");
|
||||
ALTER TABLE "transactions" ADD FOREIGN KEY ("category_id") REFERENCES "categories" ("id");
|
||||
|
||||
CREATE TABLE category_groups (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
budget_id uuid NOT NULL,
|
||||
name varchar(50) NOT NULL
|
||||
);
|
||||
ALTER TABLE "category_groups" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
|
||||
|
||||
CREATE TABLE categories (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
category_group_id uuid NOT NULL,
|
||||
name varchar(50) NOT NULL
|
||||
);
|
||||
ALTER TABLE "categories" ADD FOREIGN KEY ("category_group_id") REFERENCES "category_group" ("id");
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE transactions;
|
||||
DROP TABLE accounts;
|
||||
DROP TABLE payees;
|
||||
DROP TABLE categories;
|
||||
DROP TABLE category_groups;
|
||||
DROP TABLE user_budgets;
|
||||
DROP TABLE budgets;
|
||||
DROP TABLE users;
|
||||
DROP EXTENSION "uuid-ossp";
|
||||
DROP TABLE users;
|
Loading…
x
Reference in New Issue
Block a user