· 7 years ago · Feb 25, 2019, 11:40 AM
1--
2-- PostgreSQL database dump
3--
4
5-- Dumped from database version 10.4
6-- Dumped by pg_dump version 10.4
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: intarray; Type: EXTENSION; Schema: -; Owner:
34--
35
36CREATE EXTENSION IF NOT EXISTS intarray WITH SCHEMA public;
37
38
39--
40-- Name: EXTENSION intarray; Type: COMMENT; Schema: -; Owner:
41--
42
43COMMENT ON EXTENSION intarray IS 'functions, operators, and index support for 1-D arrays of integers';
44
45
46SET default_tablespace = '';
47
48SET default_with_oids = false;
49
50--
51-- Name: channel_member; Type: TABLE; Schema: public; Owner: postgres
52--
53
54CREATE TABLE public.channel_member (
55 created_at timestamp with time zone NOT NULL,
56 updated_at timestamp with time zone NOT NULL,
57 channel_id integer NOT NULL,
58 user_id integer NOT NULL
59);
60
61
62ALTER TABLE public.channel_member OWNER TO postgres;
63
64--
65-- Name: channels; Type: TABLE; Schema: public; Owner: postgres
66--
67
68CREATE TABLE public.channels (
69 id bigint NOT NULL,
70 name character varying(255),
71 public boolean DEFAULT true,
72 dm boolean DEFAULT false,
73 created_at timestamp with time zone NOT NULL,
74 updated_at timestamp with time zone NOT NULL,
75 team_id integer
76);
77
78
79ALTER TABLE public.channels OWNER TO postgres;
80
81--
82-- Name: channels_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
83--
84
85CREATE SEQUENCE public.channels_id_seq
86 START WITH 1
87 INCREMENT BY 1
88 NO MINVALUE
89 NO MAXVALUE
90 CACHE 1;
91
92
93ALTER TABLE public.channels_id_seq OWNER TO postgres;
94
95--
96-- Name: channels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
97--
98
99ALTER SEQUENCE public.channels_id_seq OWNED BY public.channels.id;
100
101
102--
103-- Name: direct_messages; Type: TABLE; Schema: public; Owner: postgres
104--
105
106CREATE TABLE public.direct_messages (
107 id integer NOT NULL,
108 text character varying(255),
109 created_at timestamp with time zone NOT NULL,
110 updated_at timestamp with time zone NOT NULL,
111 team_id integer,
112 receiver_id integer,
113 sender_id integer
114);
115
116
117ALTER TABLE public.direct_messages OWNER TO postgres;
118
119--
120-- Name: direct_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
121--
122
123CREATE SEQUENCE public.direct_messages_id_seq
124 START WITH 1
125 INCREMENT BY 1
126 NO MINVALUE
127 NO MAXVALUE
128 CACHE 1;
129
130
131ALTER TABLE public.direct_messages_id_seq OWNER TO postgres;
132
133--
134-- Name: direct_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
135--
136
137ALTER SEQUENCE public.direct_messages_id_seq OWNED BY public.direct_messages.id;
138
139
140--
141-- Name: member; Type: TABLE; Schema: public; Owner: postgres
142--
143
144CREATE TABLE public.member (
145 created_at timestamp with time zone NOT NULL,
146 updated_at timestamp with time zone NOT NULL,
147 user_id integer NOT NULL,
148 team_id integer NOT NULL
149);
150
151
152ALTER TABLE public.member OWNER TO postgres;
153
154--
155-- Name: members; Type: TABLE; Schema: public; Owner: postgres
156--
157
158CREATE TABLE public.members (
159 admin boolean DEFAULT false,
160 created_at timestamp with time zone NOT NULL,
161 updated_at timestamp with time zone NOT NULL,
162 user_id integer NOT NULL,
163 team_id integer NOT NULL
164);
165
166
167ALTER TABLE public.members OWNER TO postgres;
168
169--
170-- Name: messages; Type: TABLE; Schema: public; Owner: postgres
171--
172
173CREATE TABLE public.messages (
174 id integer NOT NULL,
175 text character varying(255),
176 url character varying(255),
177 filetype character varying(255),
178 created_at timestamp with time zone NOT NULL,
179 updated_at timestamp with time zone NOT NULL,
180 channel_id integer,
181 user_id integer
182);
183
184
185ALTER TABLE public.messages OWNER TO postgres;
186
187--
188-- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
189--
190
191CREATE SEQUENCE public.messages_id_seq
192 START WITH 1
193 INCREMENT BY 1
194 NO MINVALUE
195 NO MAXVALUE
196 CACHE 1;
197
198
199ALTER TABLE public.messages_id_seq OWNER TO postgres;
200
201--
202-- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
203--
204
205ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
206
207
208--
209-- Name: pcmembers; Type: TABLE; Schema: public; Owner: postgres
210--
211
212CREATE TABLE public.pcmembers (
213 created_at timestamp with time zone NOT NULL,
214 updated_at timestamp with time zone NOT NULL,
215 user_id integer NOT NULL,
216 channel_id integer NOT NULL
217);
218
219
220ALTER TABLE public.pcmembers OWNER TO postgres;
221
222--
223-- Name: teams; Type: TABLE; Schema: public; Owner: postgres
224--
225
226CREATE TABLE public.teams (
227 id integer NOT NULL,
228 name character varying(255),
229 created_at timestamp with time zone NOT NULL,
230 updated_at timestamp with time zone NOT NULL
231);
232
233
234ALTER TABLE public.teams OWNER TO postgres;
235
236--
237-- Name: teams_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
238--
239
240CREATE SEQUENCE public.teams_id_seq
241 START WITH 1
242 INCREMENT BY 1
243 NO MINVALUE
244 NO MAXVALUE
245 CACHE 1;
246
247
248ALTER TABLE public.teams_id_seq OWNER TO postgres;
249
250--
251-- Name: teams_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
252--
253
254ALTER SEQUENCE public.teams_id_seq OWNED BY public.teams.id;
255
256
257--
258-- Name: users; Type: TABLE; Schema: public; Owner: postgres
259--
260
261CREATE TABLE public.users (
262 id integer NOT NULL,
263 username character varying(255),
264 email character varying(255),
265 password character varying(255),
266 created_at timestamp with time zone NOT NULL,
267 updated_at timestamp with time zone NOT NULL
268);
269
270
271ALTER TABLE public.users OWNER TO postgres;
272
273--
274-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
275--
276
277CREATE SEQUENCE public.users_id_seq
278 START WITH 1
279 INCREMENT BY 1
280 NO MINVALUE
281 NO MAXVALUE
282 CACHE 1;
283
284
285ALTER TABLE public.users_id_seq OWNER TO postgres;
286
287--
288-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
289--
290
291ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
292
293
294--
295-- Name: channels id; Type: DEFAULT; Schema: public; Owner: postgres
296--
297
298ALTER TABLE ONLY public.channels ALTER COLUMN id SET DEFAULT nextval('public.channels_id_seq'::regclass);
299
300
301--
302-- Name: direct_messages id; Type: DEFAULT; Schema: public; Owner: postgres
303--
304
305ALTER TABLE ONLY public.direct_messages ALTER COLUMN id SET DEFAULT nextval('public.direct_messages_id_seq'::regclass);
306
307
308--
309-- Name: messages id; Type: DEFAULT; Schema: public; Owner: postgres
310--
311
312ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
313
314
315--
316-- Name: teams id; Type: DEFAULT; Schema: public; Owner: postgres
317--
318
319ALTER TABLE ONLY public.teams ALTER COLUMN id SET DEFAULT nextval('public.teams_id_seq'::regclass);
320
321
322--
323-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
324--
325
326ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
327
328
329--
330-- Name: channel_member channel_member_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
331--
332
333ALTER TABLE ONLY public.channel_member
334 ADD CONSTRAINT channel_member_pkey PRIMARY KEY (channel_id, user_id);
335
336
337--
338-- Name: channels channels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
339--
340
341ALTER TABLE ONLY public.channels
342 ADD CONSTRAINT channels_pkey PRIMARY KEY (id);
343
344
345--
346-- Name: direct_messages direct_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
347--
348
349ALTER TABLE ONLY public.direct_messages
350 ADD CONSTRAINT direct_messages_pkey PRIMARY KEY (id);
351
352
353--
354-- Name: member member_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
355--
356
357ALTER TABLE ONLY public.member
358 ADD CONSTRAINT member_pkey PRIMARY KEY (user_id, team_id);
359
360
361--
362-- Name: members members_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
363--
364
365ALTER TABLE ONLY public.members
366 ADD CONSTRAINT members_pkey PRIMARY KEY (user_id, team_id);
367
368
369--
370-- Name: messages messages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
371--
372
373ALTER TABLE ONLY public.messages
374 ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
375
376
377--
378-- Name: pcmembers pcmembers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
379--
380
381ALTER TABLE ONLY public.pcmembers
382 ADD CONSTRAINT pcmembers_pkey PRIMARY KEY (user_id, channel_id);
383
384
385--
386-- Name: teams teams_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
387--
388
389ALTER TABLE ONLY public.teams
390 ADD CONSTRAINT teams_name_key UNIQUE (name);
391
392
393--
394-- Name: teams teams_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
395--
396
397ALTER TABLE ONLY public.teams
398 ADD CONSTRAINT teams_pkey PRIMARY KEY (id);
399
400
401--
402-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
403--
404
405ALTER TABLE ONLY public.users
406 ADD CONSTRAINT users_email_key UNIQUE (email);
407
408
409--
410-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
411--
412
413ALTER TABLE ONLY public.users
414 ADD CONSTRAINT users_pkey PRIMARY KEY (id);
415
416
417--
418-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
419--
420
421ALTER TABLE ONLY public.users
422 ADD CONSTRAINT users_username_key UNIQUE (username);
423
424
425--
426-- Name: messages_created_at; Type: INDEX; Schema: public; Owner: postgres
427--
428
429CREATE INDEX messages_created_at ON public.messages USING btree (created_at);
430
431
432--
433-- Name: channel_member channel_member_channel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
434--
435
436ALTER TABLE ONLY public.channel_member
437 ADD CONSTRAINT channel_member_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON UPDATE CASCADE ON DELETE CASCADE;
438
439
440--
441-- Name: channel_member channel_member_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
442--
443
444ALTER TABLE ONLY public.channel_member
445 ADD CONSTRAINT channel_member_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE;
446
447
448--
449-- Name: channels channels_team_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
450--
451
452ALTER TABLE ONLY public.channels
453 ADD CONSTRAINT channels_team_id_fkey FOREIGN KEY (team_id) REFERENCES public.teams(id) ON UPDATE CASCADE ON DELETE SET NULL;
454
455
456--
457-- Name: direct_messages direct_messages_receiver_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
458--
459
460ALTER TABLE ONLY public.direct_messages
461 ADD CONSTRAINT direct_messages_receiver_id_fkey FOREIGN KEY (receiver_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
462
463
464--
465-- Name: direct_messages direct_messages_sender_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
466--
467
468ALTER TABLE ONLY public.direct_messages
469 ADD CONSTRAINT direct_messages_sender_id_fkey FOREIGN KEY (sender_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
470
471
472--
473-- Name: direct_messages direct_messages_team_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
474--
475
476ALTER TABLE ONLY public.direct_messages
477 ADD CONSTRAINT direct_messages_team_id_fkey FOREIGN KEY (team_id) REFERENCES public.teams(id) ON UPDATE CASCADE ON DELETE SET NULL;
478
479
480--
481-- Name: members members_team_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
482--
483
484ALTER TABLE ONLY public.members
485 ADD CONSTRAINT members_team_id_fkey FOREIGN KEY (team_id) REFERENCES public.teams(id) ON UPDATE CASCADE ON DELETE CASCADE;
486
487
488--
489-- Name: members members_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
490--
491
492ALTER TABLE ONLY public.members
493 ADD CONSTRAINT members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE;
494
495
496--
497-- Name: messages messages_channel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
498--
499
500ALTER TABLE ONLY public.messages
501 ADD CONSTRAINT messages_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON UPDATE CASCADE ON DELETE SET NULL;
502
503
504--
505-- Name: messages messages_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
506--
507
508ALTER TABLE ONLY public.messages
509 ADD CONSTRAINT messages_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
510
511
512--
513-- Name: pcmembers pcmembers_channel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
514--
515
516ALTER TABLE ONLY public.pcmembers
517 ADD CONSTRAINT pcmembers_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES public.channels(id) ON UPDATE CASCADE ON DELETE CASCADE;
518
519
520--
521-- Name: pcmembers pcmembers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
522--
523
524ALTER TABLE ONLY public.pcmembers
525 ADD CONSTRAINT pcmembers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE;
526
527
528--
529-- PostgreSQL database dump complete
530--