Skip to content
This repository was archived by the owner on Nov 26, 2018. It is now read-only.

Commit 508808c

Browse files
committed
Fixes SQL
Fixes #45, #27
1 parent 1b86d56 commit 508808c

File tree

2 files changed

+273
-36
lines changed

2 files changed

+273
-36
lines changed

sql/botbot_sample.dump

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
-- Data for Name: bots_chatbot; Type: TABLE DATA; Schema: public; Owner: botbot
33
--
44

5-
COPY bots_chatbot (id, connection, is_active, server, server_password, password, real_name, nick) FROM stdin WITH CSV;
6-
1,"nick=>botbot-test1,server=>chat.freenode.net:6697,password=>secret-password,realname=>https://botbot.me",t,chat.freenode.net:6697,,secret-password,https://botbot.me,botbot-test1
5+
COPY bots_chatbot (id, is_active, server, server_password, server_identifier, password, real_name, nick, slug, max_channels) FROM stdin WITH CSV;
6+
1,t,chat.freenode.net:6697,,chat-freenode-net-6697.botbot-test1,secret-password,https://botbot.me,botbot-test1,freenode,200
77
\.
88

99
--
1010
-- Data for Name: bots_channel; Type: TABLE DATA; Schema: public; Owner: botbot
1111
--
1212

13-
COPY bots_channel (id, chatbot_id, name, slug, is_public, is_active, password, is_featured) FROM stdin WITH CSV;
14-
1,1,#botbot-test,botbot-test,t,t,\n,f
13+
COPY bots_channel (id, created, updated, name, slug, private_slug, password, is_public, is_featured, fingerprint, public_kudos, notes, chatbot_id, status) FROM stdin WITH CSV;
14+
1,2017-05-30 14:48:10.559787-06,2017-05-30 15:47:48.704735-06,#botbot-test,botbot-test,,"",t,f,e193ef0f-aeae-4aa6-a17f-82897fa4c9c8,t,"",1,ACTIVE
1515
\.

sql/schema.sql

Lines changed: 269 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,269 @@
1-
BEGIN;
2-
CREATE TABLE "bots_chatbot" (
3-
"id" serial NOT NULL PRIMARY KEY,
4-
"is_active" boolean NOT NULL,
5-
"connection" hstore NOT NULL,
6-
"server" varchar(100) NOT NULL,
7-
"server_password" varchar(100),
8-
"nick" varchar(64) NOT NULL,
9-
"password" varchar(100),
10-
"real_name" varchar(250) NOT NULL
11-
)
12-
;
13-
CREATE TABLE "bots_channel" (
14-
"id" serial NOT NULL PRIMARY KEY,
15-
"chatbot_id" integer NOT NULL REFERENCES "bots_chatbot" ("id") DEFERRABLE INITIALLY DEFERRED,
16-
"name" varchar(250) NOT NULL,
17-
"slug" varchar(50) UNIQUE,
18-
"password" varchar(250),
19-
"is_public" boolean NOT NULL,
20-
"is_active" boolean NOT NULL,
21-
"is_featured" boolean NOT NULL
22-
)
23-
;
24-
CREATE TABLE "bots_usercount" (
25-
"id" serial NOT NULL PRIMARY KEY,
26-
"channel_id" integer NOT NULL REFERENCES "bots_channel" ("id") DEFERRABLE INITIALLY DEFERRED,
27-
"dt" date NOT NULL,
28-
"counts" int[]
29-
)
30-
;
31-
32-
COMMIT;
1+
-- pg_dump --schema-only --no-owner --table bots_chatbot --table bots_channel --table bots_usercount botbot > sql/schema.sql
2+
--
3+
-- PostgreSQL database dump
4+
--
5+
6+
-- Dumped from database version 9.6.2
7+
-- Dumped by pg_dump version 9.6.2
8+
9+
SET statement_timeout = 0;
10+
SET lock_timeout = 0;
11+
SET idle_in_transaction_session_timeout = 0;
12+
SET client_encoding = 'UTF8';
13+
SET standard_conforming_strings = on;
14+
SET check_function_bodies = false;
15+
SET client_min_messages = warning;
16+
SET row_security = off;
17+
18+
SET search_path = public, pg_catalog;
19+
20+
SET default_tablespace = '';
21+
22+
SET default_with_oids = false;
23+
24+
--
25+
-- Name: bots_channel; Type: TABLE; Schema: public; Owner: -
26+
--
27+
28+
CREATE TABLE bots_channel (
29+
id integer NOT NULL,
30+
created timestamp with time zone NOT NULL,
31+
updated timestamp with time zone NOT NULL,
32+
name character varying(250) NOT NULL,
33+
slug character varying(50) NOT NULL,
34+
private_slug character varying(50),
35+
password character varying(250),
36+
is_public boolean NOT NULL,
37+
is_featured boolean NOT NULL,
38+
fingerprint character varying(36),
39+
public_kudos boolean NOT NULL,
40+
notes text NOT NULL,
41+
chatbot_id integer NOT NULL,
42+
status character varying(20) NOT NULL
43+
);
44+
45+
46+
--
47+
-- Name: bots_channel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
48+
--
49+
50+
CREATE SEQUENCE bots_channel_id_seq
51+
START WITH 1
52+
INCREMENT BY 1
53+
NO MINVALUE
54+
NO MAXVALUE
55+
CACHE 1;
56+
57+
58+
--
59+
-- Name: bots_channel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
60+
--
61+
62+
ALTER SEQUENCE bots_channel_id_seq OWNED BY bots_channel.id;
63+
64+
65+
--
66+
-- Name: bots_chatbot; Type: TABLE; Schema: public; Owner: -
67+
--
68+
69+
CREATE TABLE bots_chatbot (
70+
id integer NOT NULL,
71+
is_active boolean NOT NULL,
72+
server character varying(100) NOT NULL,
73+
server_password character varying(100),
74+
server_identifier character varying(164) NOT NULL,
75+
nick character varying(64) NOT NULL,
76+
password character varying(100),
77+
real_name character varying(250) NOT NULL,
78+
slug character varying(50) NOT NULL,
79+
max_channels integer NOT NULL
80+
);
81+
82+
83+
--
84+
-- Name: bots_chatbot_id_seq; Type: SEQUENCE; Schema: public; Owner: -
85+
--
86+
87+
CREATE SEQUENCE bots_chatbot_id_seq
88+
START WITH 1
89+
INCREMENT BY 1
90+
NO MINVALUE
91+
NO MAXVALUE
92+
CACHE 1;
93+
94+
95+
--
96+
-- Name: bots_chatbot_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
97+
--
98+
99+
ALTER SEQUENCE bots_chatbot_id_seq OWNED BY bots_chatbot.id;
100+
101+
102+
--
103+
-- Name: bots_usercount; Type: TABLE; Schema: public; Owner: -
104+
--
105+
106+
CREATE TABLE bots_usercount (
107+
id integer NOT NULL,
108+
dt date NOT NULL,
109+
counts integer[],
110+
channel_id integer NOT NULL
111+
);
112+
113+
114+
--
115+
-- Name: bots_usercount_id_seq; Type: SEQUENCE; Schema: public; Owner: -
116+
--
117+
118+
CREATE SEQUENCE bots_usercount_id_seq
119+
START WITH 1
120+
INCREMENT BY 1
121+
NO MINVALUE
122+
NO MAXVALUE
123+
CACHE 1;
124+
125+
126+
--
127+
-- Name: bots_usercount_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
128+
--
129+
130+
ALTER SEQUENCE bots_usercount_id_seq OWNED BY bots_usercount.id;
131+
132+
133+
--
134+
-- Name: bots_channel id; Type: DEFAULT; Schema: public; Owner: -
135+
--
136+
137+
ALTER TABLE ONLY bots_channel ALTER COLUMN id SET DEFAULT nextval('bots_channel_id_seq'::regclass);
138+
139+
140+
--
141+
-- Name: bots_chatbot id; Type: DEFAULT; Schema: public; Owner: -
142+
--
143+
144+
ALTER TABLE ONLY bots_chatbot ALTER COLUMN id SET DEFAULT nextval('bots_chatbot_id_seq'::regclass);
145+
146+
147+
--
148+
-- Name: bots_usercount id; Type: DEFAULT; Schema: public; Owner: -
149+
--
150+
151+
ALTER TABLE ONLY bots_usercount ALTER COLUMN id SET DEFAULT nextval('bots_usercount_id_seq'::regclass);
152+
153+
154+
--
155+
-- Name: bots_channel bots_channel_name_2eb90853f7a0f4bc_uniq; Type: CONSTRAINT; Schema: public; Owner: -
156+
--
157+
158+
ALTER TABLE ONLY bots_channel
159+
ADD CONSTRAINT bots_channel_name_2eb90853f7a0f4bc_uniq UNIQUE (name, chatbot_id);
160+
161+
162+
--
163+
-- Name: bots_channel bots_channel_pkey; Type: CONSTRAINT; Schema: public; Owner: -
164+
--
165+
166+
ALTER TABLE ONLY bots_channel
167+
ADD CONSTRAINT bots_channel_pkey PRIMARY KEY (id);
168+
169+
170+
--
171+
-- Name: bots_channel bots_channel_private_slug_key; Type: CONSTRAINT; Schema: public; Owner: -
172+
--
173+
174+
ALTER TABLE ONLY bots_channel
175+
ADD CONSTRAINT bots_channel_private_slug_key UNIQUE (private_slug);
176+
177+
178+
--
179+
-- Name: bots_channel bots_channel_slug_7ed9a1a261704004_uniq; Type: CONSTRAINT; Schema: public; Owner: -
180+
--
181+
182+
ALTER TABLE ONLY bots_channel
183+
ADD CONSTRAINT bots_channel_slug_7ed9a1a261704004_uniq UNIQUE (slug, chatbot_id);
184+
185+
186+
--
187+
-- Name: bots_chatbot bots_chatbot_pkey; Type: CONSTRAINT; Schema: public; Owner: -
188+
--
189+
190+
ALTER TABLE ONLY bots_chatbot
191+
ADD CONSTRAINT bots_chatbot_pkey PRIMARY KEY (id);
192+
193+
194+
--
195+
-- Name: bots_usercount bots_usercount_pkey; Type: CONSTRAINT; Schema: public; Owner: -
196+
--
197+
198+
ALTER TABLE ONLY bots_usercount
199+
ADD CONSTRAINT bots_usercount_pkey PRIMARY KEY (id);
200+
201+
202+
--
203+
-- Name: bots_channel_2dbcba41; Type: INDEX; Schema: public; Owner: -
204+
--
205+
206+
CREATE INDEX bots_channel_2dbcba41 ON bots_channel USING btree (slug);
207+
208+
209+
--
210+
-- Name: bots_channel_78239581; Type: INDEX; Schema: public; Owner: -
211+
--
212+
213+
CREATE INDEX bots_channel_78239581 ON bots_channel USING btree (chatbot_id);
214+
215+
216+
--
217+
-- Name: bots_channel_private_slug_159f495e180a884e_like; Type: INDEX; Schema: public; Owner: -
218+
--
219+
220+
CREATE INDEX bots_channel_private_slug_159f495e180a884e_like ON bots_channel USING btree (private_slug varchar_pattern_ops);
221+
222+
223+
--
224+
-- Name: bots_channel_slug_5af8c5a20a5fbc3a_like; Type: INDEX; Schema: public; Owner: -
225+
--
226+
227+
CREATE INDEX bots_channel_slug_5af8c5a20a5fbc3a_like ON bots_channel USING btree (slug varchar_pattern_ops);
228+
229+
230+
--
231+
-- Name: bots_chatbot_2dbcba41; Type: INDEX; Schema: public; Owner: -
232+
--
233+
234+
CREATE INDEX bots_chatbot_2dbcba41 ON bots_chatbot USING btree (slug);
235+
236+
237+
--
238+
-- Name: bots_chatbot_slug_58696fc5be763136_like; Type: INDEX; Schema: public; Owner: -
239+
--
240+
241+
CREATE INDEX bots_chatbot_slug_58696fc5be763136_like ON bots_chatbot USING btree (slug varchar_pattern_ops);
242+
243+
244+
--
245+
-- Name: bots_usercount_72eb6c85; Type: INDEX; Schema: public; Owner: -
246+
--
247+
248+
CREATE INDEX bots_usercount_72eb6c85 ON bots_usercount USING btree (channel_id);
249+
250+
251+
--
252+
-- Name: bots_channel bots_channel_chatbot_id_4185ac24f448d436_fk_bots_chatbot_id; Type: FK CONSTRAINT; Schema: public; Owner: -
253+
--
254+
255+
ALTER TABLE ONLY bots_channel
256+
ADD CONSTRAINT bots_channel_chatbot_id_4185ac24f448d436_fk_bots_chatbot_id FOREIGN KEY (chatbot_id) REFERENCES bots_chatbot(id) DEFERRABLE INITIALLY DEFERRED;
257+
258+
259+
--
260+
-- Name: bots_usercount bots_usercount_channel_id_27c71f9cd90272cf_fk_bots_channel_id; Type: FK CONSTRAINT; Schema: public; Owner: -
261+
--
262+
263+
ALTER TABLE ONLY bots_usercount
264+
ADD CONSTRAINT bots_usercount_channel_id_27c71f9cd90272cf_fk_bots_channel_id FOREIGN KEY (channel_id) REFERENCES bots_channel(id) DEFERRABLE INITIALLY DEFERRED;
265+
266+
267+
--
268+
-- PostgreSQL database dump complete
269+
--

0 commit comments

Comments
 (0)