-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpersfin_schema.sql
More file actions
53 lines (48 loc) · 1.31 KB
/
Copy pathpersfin_schema.sql
File metadata and controls
53 lines (48 loc) · 1.31 KB
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
CREATE TABLE account (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT
);
INSERT INTO account
(name)
VALUES
('Discover'),
('USAA Checking')
;
CREATE TABLE transaction (
id SERIAL NOT NULL PRIMARY KEY,
account_id INTEGER NOT NULL REFERENCES account(id),
merchant VARCHAR(200),
date DATE,
amount NUMERIC,
amount_corrected NUMERIC,
email_message_id TEXT,
source TEXT,
created_date TIMESTAMP WITH TIME ZONE,
is_verified BOOLEAN NOT NULL,
verified_by INTEGER REFERENCES persfin_user(id),
verified_date TIMESTAMP WITH TIME ZONE,
is_cleared BOOLEAN,
attributed_to INTEGER REFERENCES persfin_user(id)
);
CREATE TABLE persfin_user (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT UNIQUE,
email TEXT,
is_verifier BOOLEAN NOT NULL,
is_superuser BOOLEAN NOT NULL
);
INSERT INTO persfin_user
(name, email, is_verifier)
VALUES
('Matt', 'mpklein+persfin@gmail.com', true),
('Ann', 'mpklein+persfin-ann@gmail.com', true)
('Neither/both/family', null, false)
;
CREATE TABLE verification_attempt (
id SERIAL NOT NULL PRIMARY KEY,
transaction_id INTEGER REFERENCES transaction(id),
asked_of INTEGER REFERENCES persfin_user(id),
did_verify BOOLEAN,
attempt_sent TIMESTAMP WITH TIME ZONE,
attempt_replied_to TIMESTAMP WITH TIME ZONE
);