1
drop table klaviyo_profile;
2
drop table klaviyo_profile;
3
drop table klaviyo_event;
4
create table klaviyo_profile (
5
id varchar(32) collate Latin1_General_CS_AS not null primary key nonclustered not enforced,
6
external_id nvarchar(255),
7
email nvarchar(255),
8
phone_number nvarchar(255),
9
first_name nvarchar(255),
10
last_name nvarchar(255),
11
title nvarchar(255),
12
organization nvarchar(255),
13
properties nvarchar(max),
14
image nvarchar(255),
15
location_address1 nvarchar(255),
16
location_address2 nvarchar(255),
17
location_city nvarchar(255),
18
location_country nvarchar(255),
19
location_latitude nvarchar(255),
20
location_longitude nvarchar(255),
21
location_region nvarchar(255),
22
location_zip nvarchar(255),
23
created datetime2,
24
updated datetime2
25
) with (clustered index (id), distribution = hash(id));
26
create index external_id_index on klaviyo_profile (external_id);
27
create index email_index on klaviyo_profile (email);
28
create index phone_number_index on klaviyo_profile (phone_number);
29
create table klaviyo_event (
30
id varchar(32) collate Latin1_General_CS_AS not null primary key nonclustered not enforced,
31
metric_id nvarchar(255) not null,
32
profile_id nvarchar(255),
33
event_properties nvarchar(max),
34
datetime datetime2,
35
uuid varchar(255)
36
) with (clustered index(id), distribution = hash(id));
37
create index event_profile_index on klaviyo_event (profile_id);
38
create index event_metric_index on klaviyo_event (metric_id);
39
create index event_datetime_index on klaviyo_event (datetime);
40
create table klaviyo_metric (
41
id varchar(6) collate Latin1_General_BIN not null primary key nonclustered not enforced,
42
name varchar(255) not null,
43
integration_id varchar(50) collate Latin1_General_BIN not null,
44
integration_name varchar(255) not null,
45
integration_category varchar(255) not null,
46
created datetime2,
47
updated datetime2
48
) with (clustered index(id), distribution = hash(id));
49
50