forked from HyperCable/hypercable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyper_structure.sql
157 lines (117 loc) · 4.17 KB
/
hyper_structure.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
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_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 xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: timescaledb; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS timescaledb WITH SCHEMA public;
--
-- Name: EXTENSION timescaledb; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION timescaledb IS 'Enables scalable inserts and complex queries for time-series data';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.events (
event_name character varying DEFAULT 'page_view'::character varying,
site_id character varying NOT NULL,
session_id character varying NOT NULL,
client_id character varying NOT NULL,
user_id character varying,
tracking_id character varying NOT NULL,
protocol_version character varying DEFAULT '2'::character varying,
data_source character varying DEFAULT 'web'::character varying,
session_engagement boolean DEFAULT false,
engagement_time integer,
session_count integer,
request_number integer,
location_url character varying,
hostname character varying,
path character varying,
title character varying,
user_agent character varying,
ip character varying,
referrer character varying,
referrer_source character varying,
screen_resolution character varying,
user_language character varying,
country character varying,
region character varying,
city character varying,
latitude double precision,
longitude double precision,
browser character varying,
os character varying,
device_type character varying,
user_props jsonb DEFAULT '{}'::jsonb,
event_props jsonb DEFAULT '{}'::jsonb,
started_at timestamp without time zone NOT NULL,
raw_event jsonb DEFAULT '{}'::jsonb,
traffic_campaign character varying,
traffic_medium character varying,
traffic_source character varying,
request_params jsonb DEFAULT '"{}"'::jsonb
);
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);
--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: events_started_at_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_started_at_idx ON public.events USING btree (started_at DESC);
--
-- Name: index_events_on_site_id_and_session_id_and_started_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_events_on_site_id_and_session_id_and_started_at ON public.events USING btree (site_id, session_id, started_at DESC);
--
-- Name: events ts_insert_blocker; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER ts_insert_blocker BEFORE INSERT ON public.events FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker();
--
-- Name: events event_access; Type: POLICY; Schema: public; Owner: -
--
CREATE POLICY event_access ON public.events FOR SELECT USING (((site_id)::text = (CURRENT_USER)::text));
--
-- PostgreSQL database dump complete
--
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20210213182643'),
('20210226015643'),
('20210226091913'),
('20210311071834'),
('20210311151807'),
('20210311173212'),
('20210311175013'),
('20210312171927');