· 8 years ago · Mar 25, 2018, 05:54 PM
1--
2-- PostgreSQL database dump
3--
4
5-- Dumped from database version 9.6.8
6-- Dumped by pg_dump version 9.6.8
7
8SET statement_timeout = 0;
9SET lock_timeout = 0;
10SET idle_in_transaction_session_timeout = 0;
11SET client_encoding = 'UTF8';
12SET standard_conforming_strings = on;
13SELECT pg_catalog.set_config('search_path', '', false);
14SET check_function_bodies = false;
15SET client_min_messages = warning;
16SET row_security = off;
17
18--
19-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
20--
21
22CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
23
24
25--
26-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
27--
28
29COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
30
31
32--
33-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner:
34--
35
36CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
37
38
39--
40-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
41--
42
43COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
44
45
46--
47-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner:
48--
49
50CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
51
52
53--
54-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner:
55--
56
57COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
58
59
60--
61-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner:
62--
63
64CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
65
66
67--
68-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
69--
70
71COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
72
73
74--
75-- Name: borrower_id_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
76--
77
78CREATE SEQUENCE public.borrower_id_seq
79 START WITH 1
80 INCREMENT BY 1
81 NO MINVALUE
82 NO MAXVALUE
83 CACHE 1
84 CYCLE;
85
86
87ALTER TABLE public.borrower_id_seq OWNER TO fc_demo;
88
89SET default_tablespace = '';
90
91SET default_with_oids = false;
92
93--
94-- Name: borrowers; Type: TABLE; Schema: public; Owner: fc_demo
95--
96
97CREATE TABLE public.borrowers (
98 id bigint DEFAULT nextval('public.borrower_id_seq'::regclass) NOT NULL,
99 name text NOT NULL,
100 registration_date timestamp without time zone,
101 account_balance numeric NOT NULL
102);
103
104
105ALTER TABLE public.borrowers OWNER TO fc_demo;
106
107--
108-- Name: investor_id_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
109--
110
111CREATE SEQUENCE public.investor_id_seq
112 START WITH 1
113 INCREMENT BY 1
114 NO MINVALUE
115 NO MAXVALUE
116 CACHE 1
117 CYCLE;
118
119
120ALTER TABLE public.investor_id_seq OWNER TO fc_demo;
121
122--
123-- Name: investors; Type: TABLE; Schema: public; Owner: fc_demo
124--
125
126CREATE TABLE public.investors (
127 id bigint DEFAULT nextval('public.investor_id_seq'::regclass) NOT NULL,
128 name text NOT NULL,
129 registration_date timestamp without time zone
130);
131
132
133ALTER TABLE public.investors OWNER TO fc_demo;
134
135--
136-- Name: loan_id_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
137--
138
139CREATE SEQUENCE public.loan_id_seq
140 START WITH 1
141 INCREMENT BY 1
142 NO MINVALUE
143 NO MAXVALUE
144 CACHE 1
145 CYCLE;
146
147
148ALTER TABLE public.loan_id_seq OWNER TO fc_demo;
149
150--
151-- Name: loan_part_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
152--
153
154CREATE SEQUENCE public.loan_part_seq
155 START WITH 1
156 INCREMENT BY 1
157 NO MINVALUE
158 NO MAXVALUE
159 CACHE 1
160 CYCLE;
161
162
163ALTER TABLE public.loan_part_seq OWNER TO fc_demo;
164
165--
166-- Name: loan_part_transfer_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
167--
168
169CREATE SEQUENCE public.loan_part_transfer_seq
170 START WITH 1
171 INCREMENT BY 1
172 NO MINVALUE
173 NO MAXVALUE
174 CACHE 1
175 CYCLE;
176
177
178ALTER TABLE public.loan_part_transfer_seq OWNER TO fc_demo;
179
180--
181-- Name: loan_part_transfers; Type: TABLE; Schema: public; Owner: fc_demo
182--
183
184CREATE TABLE public.loan_part_transfers (
185 id bigint DEFAULT nextval('public.loan_part_transfer_seq'::regclass) NOT NULL,
186 loan_part_id bigint NOT NULL,
187 seller bigint,
188 buyer bigint NOT NULL,
189 "timestamp" timestamp without time zone NOT NULL
190);
191
192
193ALTER TABLE public.loan_part_transfers OWNER TO fc_demo;
194
195--
196-- Name: loan_parts; Type: TABLE; Schema: public; Owner: fc_demo
197--
198
199CREATE TABLE public.loan_parts (
200 id bigint DEFAULT nextval('public.loan_part_seq'::regclass) NOT NULL,
201 investor_id bigint,
202 loan_id bigint NOT NULL,
203 proportion numeric NOT NULL,
204 amount numeric NOT NULL
205);
206
207
208ALTER TABLE public.loan_parts OWNER TO fc_demo;
209
210--
211-- Name: loans; Type: TABLE; Schema: public; Owner: fc_demo
212--
213
214CREATE TABLE public.loans (
215 id bigint DEFAULT nextval('public.loan_id_seq'::regclass) NOT NULL,
216 borrower_id bigint NOT NULL,
217 amount numeric NOT NULL,
218 amount_funded numeric NOT NULL,
219 principal_paid numeric NOT NULL,
220 interest_paid numeric NOT NULL,
221 term integer NOT NULL,
222 funded boolean NOT NULL,
223 rate numeric NOT NULL
224);
225
226
227ALTER TABLE public.loans OWNER TO fc_demo;
228
229--
230-- Name: payment_id_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
231--
232
233CREATE SEQUENCE public.payment_id_seq
234 START WITH 1
235 INCREMENT BY 1
236 NO MINVALUE
237 NO MAXVALUE
238 CACHE 1;
239
240
241ALTER TABLE public.payment_id_seq OWNER TO fc_demo;
242
243--
244-- Name: payments; Type: TABLE; Schema: public; Owner: fc_demo
245--
246
247CREATE TABLE public.payments (
248 "timestamp" timestamp without time zone NOT NULL,
249 borrower_id bigint NOT NULL,
250 loan_id bigint NOT NULL,
251 month integer NOT NULL,
252 principal numeric NOT NULL,
253 interest numeric NOT NULL
254);
255
256
257ALTER TABLE public.payments OWNER TO fc_demo;
258
259--
260-- Name: schema_migrations_seq; Type: SEQUENCE; Schema: public; Owner: fc_demo
261--
262
263CREATE SEQUENCE public.schema_migrations_seq
264 START WITH 1
265 INCREMENT BY 1
266 NO MINVALUE
267 NO MAXVALUE
268 CACHE 1
269 CYCLE;
270
271
272ALTER TABLE public.schema_migrations_seq OWNER TO fc_demo;
273
274--
275-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: fc_demo
276--
277
278CREATE TABLE public.schema_migrations (
279 id bigint DEFAULT nextval('public.schema_migrations_seq'::regclass) NOT NULL,
280 "timestamp" timestamp without time zone NOT NULL
281);
282
283
284ALTER TABLE public.schema_migrations OWNER TO fc_demo;
285
286--
287-- Name: borrowers borrowers_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
288--
289
290ALTER TABLE ONLY public.borrowers
291 ADD CONSTRAINT borrowers_pkey PRIMARY KEY (id);
292
293
294--
295-- Name: investors investors_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
296--
297
298ALTER TABLE ONLY public.investors
299 ADD CONSTRAINT investors_pkey PRIMARY KEY (id);
300
301
302--
303-- Name: loan_part_transfers loan_part_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
304--
305
306ALTER TABLE ONLY public.loan_part_transfers
307 ADD CONSTRAINT loan_part_transfers_pkey PRIMARY KEY (id);
308
309
310--
311-- Name: loan_parts loan_parts_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
312--
313
314ALTER TABLE ONLY public.loan_parts
315 ADD CONSTRAINT loan_parts_pkey PRIMARY KEY (id);
316
317
318--
319-- Name: loans loans_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
320--
321
322ALTER TABLE ONLY public.loans
323 ADD CONSTRAINT loans_pkey PRIMARY KEY (id);
324
325
326--
327-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: fc_demo
328--
329
330ALTER TABLE ONLY public.schema_migrations
331 ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (id);
332
333
334--
335-- Name: loan_part_transfers_buyer_idx; Type: INDEX; Schema: public; Owner: fc_demo
336--
337
338CREATE INDEX loan_part_transfers_buyer_idx ON public.loan_part_transfers USING btree (buyer);
339
340
341--
342-- Name: loan_part_transfers_loan_part_id_idx; Type: INDEX; Schema: public; Owner: fc_demo
343--
344
345CREATE INDEX loan_part_transfers_loan_part_id_idx ON public.loan_part_transfers USING btree (loan_part_id);
346
347
348--
349-- Name: loan_part_transfers_seller_idx; Type: INDEX; Schema: public; Owner: fc_demo
350--
351
352CREATE INDEX loan_part_transfers_seller_idx ON public.loan_part_transfers USING btree (seller);
353
354
355--
356-- Name: loan_part_transfers_timestamp_idx; Type: INDEX; Schema: public; Owner: fc_demo
357--
358
359CREATE INDEX loan_part_transfers_timestamp_idx ON public.loan_part_transfers USING btree ("timestamp");
360
361
362--
363-- Name: loan_parts_loan_id_idx; Type: INDEX; Schema: public; Owner: fc_demo
364--
365
366CREATE INDEX loan_parts_loan_id_idx ON public.loan_parts USING btree (loan_id);
367
368
369--
370-- Name: loans_borrower_id_idx; Type: INDEX; Schema: public; Owner: fc_demo
371--
372
373CREATE INDEX loans_borrower_id_idx ON public.loans USING btree (borrower_id);
374
375
376--
377-- Name: loan_part_transfers loan_part_transfers_buyer_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
378--
379
380ALTER TABLE ONLY public.loan_part_transfers
381 ADD CONSTRAINT loan_part_transfers_buyer_fkey FOREIGN KEY (buyer) REFERENCES public.investors(id);
382
383
384--
385-- Name: loan_part_transfers loan_part_transfers_loan_part_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
386--
387
388ALTER TABLE ONLY public.loan_part_transfers
389 ADD CONSTRAINT loan_part_transfers_loan_part_id_fkey FOREIGN KEY (loan_part_id) REFERENCES public.loan_parts(id);
390
391
392--
393-- Name: loan_part_transfers loan_part_transfers_seller_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
394--
395
396ALTER TABLE ONLY public.loan_part_transfers
397 ADD CONSTRAINT loan_part_transfers_seller_fkey FOREIGN KEY (seller) REFERENCES public.investors(id);
398
399
400--
401-- Name: loan_parts loan_parts_investor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
402--
403
404ALTER TABLE ONLY public.loan_parts
405 ADD CONSTRAINT loan_parts_investor_id_fkey FOREIGN KEY (investor_id) REFERENCES public.investors(id);
406
407
408--
409-- Name: loan_parts loan_parts_loan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
410--
411
412ALTER TABLE ONLY public.loan_parts
413 ADD CONSTRAINT loan_parts_loan_id_fkey FOREIGN KEY (loan_id) REFERENCES public.loans(id);
414
415
416--
417-- Name: loans loans_borrower_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
418--
419
420ALTER TABLE ONLY public.loans
421 ADD CONSTRAINT loans_borrower_id_fkey FOREIGN KEY (borrower_id) REFERENCES public.borrowers(id);
422
423
424--
425-- Name: payments payments_borrower_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
426--
427
428ALTER TABLE ONLY public.payments
429 ADD CONSTRAINT payments_borrower_id_fkey FOREIGN KEY (borrower_id) REFERENCES public.borrowers(id);
430
431
432--
433-- Name: payments payments_loan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: fc_demo
434--
435
436ALTER TABLE ONLY public.payments
437 ADD CONSTRAINT payments_loan_id_fkey FOREIGN KEY (loan_id) REFERENCES public.loans(id);
438
439
440--
441-- PostgreSQL database dump complete
442--