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 := authenticated.Group("/user")
|
||||||
user.GET("/logout", logout)
|
user.GET("/logout", logout)
|
||||||
|
|
||||||
budget := api.Group("/budget")
|
budget := authenticated.Group("/budget")
|
||||||
budget.POST("/new", h.newBudget)
|
budget.POST("/new", h.newBudget)
|
||||||
|
|
||||||
transaction := api.Group("/transaction")
|
transaction := authenticated.Group("/transaction")
|
||||||
transaction.POST("/new", h.newTransaction)
|
transaction.POST("/new", h.newTransaction)
|
||||||
transaction.POST("/import/ynab", h.importYNAB)
|
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
|
-- +goose Up
|
||||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
||||||
|
|
||||||
CREATE TABLE budgets (
|
CREATE TABLE budgets (
|
||||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
@ -35,6 +33,20 @@ CREATE TABLE payees (
|
|||||||
);
|
);
|
||||||
ALTER TABLE "payees" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
|
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 (
|
CREATE TABLE transactions (
|
||||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||||
date date NOT NULL,
|
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 ("payee_id") REFERENCES "payees" ("id");
|
||||||
ALTER TABLE "transactions" ADD FOREIGN KEY ("category_id") REFERENCES "categories" ("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
|
-- +goose Down
|
||||||
DROP TABLE transactions;
|
DROP TABLE transactions;
|
||||||
DROP TABLE accounts;
|
DROP TABLE accounts;
|
||||||
DROP TABLE payees;
|
DROP TABLE payees;
|
||||||
|
DROP TABLE categories;
|
||||||
|
DROP TABLE category_groups;
|
||||||
DROP TABLE user_budgets;
|
DROP TABLE user_budgets;
|
||||||
DROP TABLE budgets;
|
DROP TABLE budgets;
|
||||||
DROP TABLE users;
|
DROP TABLE users;
|
||||||
DROP EXTENSION "uuid-ossp";
|
|
Loading…
x
Reference in New Issue
Block a user