-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfbapipolads_schema.sql
401 lines (279 loc) · 8.46 KB
/
fbapipolads_schema.sql
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.14
-- Dumped by pg_dump version 9.5.14
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: ad_categories; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.ad_categories (
name character varying,
id integer NOT NULL
);
ALTER TABLE public.ad_categories OWNER TO db_owner_name;
--
-- Name: ad_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: db_owner_name
--
CREATE SEQUENCE public.ad_categories_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.ad_categories_id_seq OWNER TO db_owner_name;
--
-- Name: ad_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: db_owner_name
--
ALTER SEQUENCE public.ad_categories_id_seq OWNED BY public.ad_categories.id;
--
-- Name: ad_sponsors; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.ad_sponsors (
id integer NOT NULL,
name character varying(2000),
federal_candidate boolean,
nyu_category character varying,
partisan_lean character varying,
cmte_fec_id text,
parent_ad_sponsor_id integer,
cmte_ein text
);
ALTER TABLE public.ad_sponsors OWNER TO db_owner_name;
--
-- Name: ad_sponsor_id_seq; Type: SEQUENCE; Schema: public; Owner: db_owner_name
--
CREATE SEQUENCE public.ad_sponsor_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.ad_sponsor_id_seq OWNER TO db_owner_name;
--
-- Name: ad_sponsor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: db_owner_name
--
ALTER SEQUENCE public.ad_sponsor_id_seq OWNED BY public.ad_sponsors.id;
--
-- Name: ads; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.ads (
text text,
start_date timestamp(4) with time zone,
end_date timestamp(4) with time zone,
creation_date timestamp(4) with time zone,
page_id bigint,
currency character varying(255),
snapshot_url character varying,
is_active boolean,
ad_sponsor_id integer,
archive_id bigint NOT NULL,
nyu_id bigint NOT NULL,
link_caption character varying,
link_description character varying,
link_title character varying,
ad_category_id integer,
ad_id bigint,
country_code character varying
);
ALTER TABLE public.ads OWNER TO db_owner_name;
--
-- Name: ads_nyu_id_seq; Type: SEQUENCE; Schema: public; Owner: db_owner_name
--
CREATE SEQUENCE public.ads_nyu_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.ads_nyu_id_seq OWNER TO db_owner_name;
--
-- Name: ads_nyu_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: db_owner_name
--
ALTER SEQUENCE public.ads_nyu_id_seq OWNED BY public.ads.nyu_id;
--
-- Name: demo_groups; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.demo_groups (
age character varying(255),
gender character varying(255),
id integer NOT NULL
);
ALTER TABLE public.demo_groups OWNER TO db_owner_name;
--
-- Name: demo_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: db_owner_name
--
CREATE SEQUENCE public.demo_groups_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.demo_groups_id_seq OWNER TO db_owner_name;
--
-- Name: demo_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: db_owner_name
--
ALTER SEQUENCE public.demo_groups_id_seq OWNED BY public.demo_groups.id;
--
-- Name: demo_impressions; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.demo_impressions (
ad_archive_id bigint,
demo_id integer,
min_impressions integer,
max_impressions integer,
min_spend integer,
max_spend integer,
crawl_date date,
nyu_id bigint,
most_recent boolean
);
ALTER TABLE public.demo_impressions OWNER TO db_owner_name;
--
-- Name: images; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.images (
image_url character varying,
image_phash character varying
);
ALTER TABLE public.images OWNER TO db_owner_name;
--
-- Name: impressions; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.impressions (
ad_archive_id bigint,
crawl_date date,
min_impressions integer,
min_spend integer,
max_impressions integer,
max_spend integer,
nyu_id bigint,
most_recent boolean
);
ALTER TABLE public.impressions OWNER TO db_owner_name;
--
-- Name: multiple_ad_categories; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.multiple_ad_categories (
ad_archive_id bigint,
ad_category_id integer
);
ALTER TABLE public.multiple_ad_categories OWNER TO db_owner_name;
--
-- Name: page_categories; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.page_categories (
page_id bigint,
category character varying
);
ALTER TABLE public.page_categories OWNER TO db_owner_name;
--
-- Name: pages; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.pages (
page_name character varying(255),
page_id bigint,
federal_candidate boolean,
url character varying,
is_deleted boolean
);
ALTER TABLE public.pages OWNER TO db_owner_name;
--
-- Name: region_impressions; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.region_impressions (
ad_archive_id bigint,
region_id integer,
min_impressions integer,
min_spend integer,
max_impressions integer,
max_spend integer,
crawl_date date,
nyu_id bigint,
most_recent boolean
);
ALTER TABLE public.region_impressions OWNER TO db_owner_name;
--
-- Name: regions; Type: TABLE; Schema: public; Owner: db_owner_name
--
CREATE TABLE public.regions (
name character varying,
id integer NOT NULL
);
ALTER TABLE public.regions OWNER TO db_owner_name;
--
-- Name: regions_id_seq; Type: SEQUENCE; Schema: public; Owner: db_owner_name
--
CREATE SEQUENCE public.regions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.regions_id_seq OWNER TO db_owner_name;
--
-- Name: regions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: db_owner_name
--
ALTER SEQUENCE public.regions_id_seq OWNED BY public.regions.id;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.ad_categories ALTER COLUMN id SET DEFAULT nextval('public.ad_categories_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.ad_sponsors ALTER COLUMN id SET DEFAULT nextval('public.ad_sponsor_id_seq'::regclass);
--
-- Name: nyu_id; Type: DEFAULT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.ads ALTER COLUMN nyu_id SET DEFAULT nextval('public.ads_nyu_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.demo_groups ALTER COLUMN id SET DEFAULT nextval('public.demo_groups_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.regions ALTER COLUMN id SET DEFAULT nextval('public.regions_id_seq'::regclass);
--
-- Name: ad_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.ad_categories
ADD CONSTRAINT ad_categories_pkey PRIMARY KEY (id);
--
-- Name: demo_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.demo_groups
ADD CONSTRAINT demo_groups_pkey PRIMARY KEY (id);
--
-- Name: regions_pkey; Type: CONSTRAINT; Schema: public; Owner: db_owner_name
--
ALTER TABLE ONLY public.regions
ADD CONSTRAINT regions_pkey PRIMARY KEY (id);
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--