~manuel-uberti/boodle

boodle/resources/sql/model.sql -rw-r--r-- 1.6 KiB
33f03bd9Manuel Uberti Bump slf4j-simple 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
CREATE USER ADMIN WITH PASSWORD 'admin';

CREATE TABLE categories (
    id serial PRIMARY KEY,
    name VARCHAR(30) NOT NULL,
    monthly_budget NUMERIC(10, 2)
);

CREATE TABLE expenses (
    id serial PRIMARY KEY,
    DATE DATE,
    id_category INTEGER REFERENCES categories (id),
    item VARCHAR(1000),
    amount NUMERIC(10, 2),
    from_savings BOOLEAN
);

CREATE TABLE aims (
    id serial PRIMARY KEY,
    name VARCHAR(30) NOT NULL,
    target NUMERIC(10, 2) NOT NULL,
    achieved BOOLEAN DEFAULT FALSE,
    achieved_on DATE
);

CREATE TABLE transactions (
    id serial PRIMARY KEY,
    id_aim INTEGER REFERENCES aims (id),
    item VARCHAR(1000),
    amount NUMERIC(10, 2),
    DATE DATE
);

CREATE TABLE savings (
    id serial PRIMARY KEY,
    item VARCHAR(1000),
    amount NUMERIC(10, 2),
    date DATE
);

CREATE TABLE funds (
    id serial PRIMARY KEY,
    name VARCHAR(30) NOT NULL,
    amount NUMERIC(10, 2),
    date DATE
);

GRANT ALL PRIVILEGES ON DATABASE "boodle" TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE categories TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE expenses TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE aims TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE transactions TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE savings TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE funds TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE categories_id_seq TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE expenses_id_seq TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE aims_id_seq TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE transactions_id_seq TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE savings_id_seq TO ADMIN;

GRANT ALL PRIVILEGES ON TABLE funds_id_seq TO ADMIN;

GRANT postgres TO ADMIN;