/
mysql_schema.sql
216 lines (178 loc) · 6.59 KB
/
mysql_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
CREATE TABLE IF NOT EXISTS dada_settings (
list varchar(16),
setting varchar(64),
value text
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_subscribers (
email_id int not null primary key auto_increment,
email varchar(80),
list varchar(16),
list_type varchar(64),
list_status char(1),
timestamp TIMESTAMP DEFAULT NOW()
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_confirmation_tokens (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
timestamp TIMESTAMP DEFAULT NOW(),
token varchar(255),
email varchar(80),
data text,
UNIQUE (token)
);
CREATE TABLE IF NOT EXISTS dada_profiles (
profile_id int not null primary key auto_increment,
email varchar(80) not null,
password text(16),
auth_code varchar(64),
update_email_auth_code varchar(64),
update_email varchar(80),
activated char(1),
CONSTRAINT UNIQUE (email)
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_profile_fields (
fields_id int not null primary key auto_increment,
email varchar(80) not null,
CONSTRAINT UNIQUE (email)
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_profile_fields_attributes (
attribute_id int not null primary key auto_increment,
field varchar(80),
label varchar(80),
fallback_value text,
required char(1) DEFAULT 0 NOT NULL,
-- I haven't made the following, but it seems like a pretty good idea...
-- sql_col_type text(16),
-- default mediumtext,
-- html_form_widget varchar(80),
-- public char(1),
CONSTRAINT UNIQUE (field)
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_profile_settings (
id int not null primary key auto_increment,
email varchar(80),
list varchar(16),
setting varchar(64),
value text
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_archives (
list varchar(16),
archive_id varchar(32),
subject text,
message mediumtext,
format text,
raw_msg mediumtext
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS dada_bounce_scores (
id int not null primary key auto_increment,
email text,
list varchar(16),
score int
);
CREATE TABLE IF NOT EXISTS dada_sessions (
id CHAR(32) NOT NULL PRIMARY KEY,
a_session TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS dada_clickthrough_urls (
url_id int not null primary key auto_increment,
redirect_id varchar(16),
msg_id text,
url text
);
CREATE TABLE IF NOT EXISTS dada_mass_mailing_event_log (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
list varchar(16),
timestamp TIMESTAMP DEFAULT NOW(),
remote_addr varchar(255),
msg_id varchar(255),
event varchar(255),
details varchar(255),
email varchar(80),
user_agent varchar(255)
);
CREATE TABLE IF NOT EXISTS dada_clickthrough_url_log (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
list varchar(16),
timestamp TIMESTAMP DEFAULT NOW(),
remote_addr varchar(255),
msg_id text,
url text,
email varchar(80),
user_agent varchar(255)
);
CREATE TABLE IF NOT EXISTS dada_password_protect_directories (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
list varchar(16),
name text,
url text,
path text,
use_custom_error_page char(1),
custom_error_page text,
default_password text,
always_use_default_password char(1)
);
CREATE TABLE IF NOT EXISTS dada_message_drafts (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
list varchar(16),
created_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_modified_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
name varchar(80),
screen varchar(80),
role varchar(80),
draft mediumtext
);
CREATE TABLE IF NOT EXISTS dada_rate_limit_hits (
user_id VARCHAR(225) NOT NULL,
action VARCHAR(225) NOT NULL,
timestamp INT UNSIGNED NOT NULL
);
CREATE TABLE IF NOT EXISTS dada_email_message_previews (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
list varchar(16),
created_timestamp TIMESTAMP DEFAULT NOW(),
vars text,
plaintext mediumtext,
html mediumtext
);
CREATE TABLE IF NOT EXISTS dada_privacy_policies (
privacy_policy_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
timestamp TIMESTAMP DEFAULT NOW(),
list varchar(16),
privacy_policy mediumtext
);
CREATE TABLE IF NOT EXISTS dada_consents (
consent_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
timestamp TIMESTAMP DEFAULT NOW(),
list varchar(16),
consent mediumtext
);
CREATE TABLE IF NOT EXISTS dada_consent_activity (
consent_activity_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
remote_addr varchar(255),
timestamp TIMESTAMP DEFAULT NOW(),
email varchar(80),
list varchar(16),
action varchar(80),
source varchar(225),
source_location varchar(225),
list_type varchar(64),
consent_session_token varchar(255),
consent_id int,
privacy_policy_id int,
FOREIGN KEY(consent_id) REFERENCES dada_consents(consent_id),
FOREIGN KEY(privacy_policy_id) REFERENCES dada_privacy_policies(privacy_policy_id)
);
CREATE TABLE IF NOT EXISTS dada_simple_auth_str (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
timestamp TIMESTAMP DEFAULT NOW(),
remote_addr varchar(255),
auth_str varchar(255),
CONSTRAINT UAS UNIQUE (auth_str)
);
CREATE INDEX dada_settings_list_index ON dada_settings (list);
CREATE INDEX
_all_index ON dada_subscribers (email(80), list, list_type, list_status, timestamp);
CREATE INDEX dada_confirmation_tokens_index ON dada_confirmation_tokens (id, timestamp, token(80), email(80));
CREATE INDEX dada_archives_list_archive_id_index ON dada_archives (list, archive_id);
CREATE INDEX dada_mass_mailing_event_log_index ON dada_mass_mailing_event_log (list,remote_addr(80), msg_id(80), event(80), timestamp);
CREATE INDEX dada_rate_limit_hits_all_index ON dada_rate_limit_hits (user_id, action(80), timestamp);
CREATE INDEX dada_consent_activity_index ON dada_consent_activity (email, list, action);