-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdb.sql
More file actions
66 lines (66 loc) · 2.58 KB
/
db.sql
File metadata and controls
66 lines (66 loc) · 2.58 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
54
55
56
57
58
59
60
61
62
63
64
65
66
CREATE EXTENSION "hstore";
CREATE EXTENSION "uuid-ossp";
BEGIN;
CREATE TABLE app_person (
id integer NOT NULL,
guid uuid NOT NULL,
first_name character varying(30),
last_name character varying(30),
email character varying(75) NOT NULL,
password character varying(128) NOT NULL,
created timestamp with time zone NOT NULL,
modified timestamp with time zone,
last_login timestamp with time zone NOT NULL,
details hstore
);
CREATE SEQUENCE app_person_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE app_person_id_seq OWNED BY app_person.id;
ALTER TABLE ONLY app_person ALTER COLUMN id SET DEFAULT nextval('app_person_id_seq'::regclass);
ALTER TABLE ONLY app_person
ADD CONSTRAINT app_person_guid_key UNIQUE (guid);
ALTER TABLE ONLY app_person
ADD CONSTRAINT app_person_pkey PRIMARY KEY (id);
CREATE INDEX app_person_email ON app_person USING btree (email);
CREATE INDEX app_person_guid ON app_person USING btree (guid);
CREATE TABLE app_request (
id integer NOT NULL,
guid uuid NOT NULL,
requester_id integer NOT NULL,
requester_guid uuid NOT NULL,
requester_email character varying(75) NOT NULL,
requested_id integer,
requested_guid uuid,
email character varying(75) NOT NULL,
created timestamp with time zone NOT NULL,
accepted timestamp with time zone,
declined timestamp with time zone,
cancelled timestamp with time zone,
is_active boolean NOT NULL,
details hstore
);
CREATE SEQUENCE app_request_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE app_request_id_seq OWNED BY app_request.id;
ALTER TABLE ONLY app_request ALTER COLUMN id SET DEFAULT nextval('app_request_id_seq'::regclass);
ALTER TABLE ONLY app_request
ADD CONSTRAINT app_request_guid_key UNIQUE (guid);
ALTER TABLE ONLY app_request
ADD CONSTRAINT app_request_pkey PRIMARY KEY (id);
CREATE INDEX app_request_by_for_active ON app_request USING btree (requester_guid, email, is_active);
CREATE INDEX app_request_details_gist ON app_request USING gist (details);
CREATE INDEX app_request_requested_id ON app_request USING btree (requested_id);
CREATE INDEX app_request_requester_id ON app_request USING btree (requester_id);
ALTER TABLE ONLY app_request
ADD CONSTRAINT app_request_requested_id_fkey FOREIGN KEY (requested_id) REFERENCES app_person(id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY app_request
ADD CONSTRAINT app_request_requester_id_fkey FOREIGN KEY (requester_id) REFERENCES app_person(id) DEFERRABLE INITIALLY DEFERRED;
COMMIT;