]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - db/statusnet.sql
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / db / statusnet.sql
1 /* local and remote users have profiles */
2
3 create table profile (
4
5     id integer auto_increment primary key comment 'unique identifier',
6     nickname varchar(64) not null comment 'nickname or username',
7     fullname varchar(255) comment 'display name',
8     profileurl varchar(255) comment 'URL, cached so we dont regenerate',
9     homepage varchar(255) comment 'identifying URL',
10     bio text comment 'descriptive biography',
11     location varchar(255) comment 'physical location',
12     lat decimal(10,7) comment 'latitude',
13     lon decimal(10,7) comment 'longitude',
14     location_id integer comment 'location id if possible',
15     location_ns integer comment 'namespace for location',
16
17     created datetime not null comment 'date this record was created',
18     modified timestamp comment 'date this record was modified',
19
20     index profile_nickname_idx (nickname),
21     FULLTEXT(nickname, fullname, location, bio, homepage)
22 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
23
24 create table avatar (
25     profile_id integer not null comment 'foreign key to profile table' references profile (id),
26     original boolean default false comment 'uploaded by user or generated?',
27     width integer not null comment 'image width',
28     height integer not null comment 'image height',
29     mediatype varchar(32) not null comment 'file type',
30     filename varchar(255) null comment 'local filename, if local',
31     url varchar(255) unique key comment 'avatar location',
32     created datetime not null comment 'date this record was created',
33     modified timestamp comment 'date this record was modified',
34
35     constraint primary key (profile_id, width, height),
36     index avatar_profile_id_idx (profile_id)
37 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
38
39 create table sms_carrier (
40     id integer primary key comment 'primary key for SMS carrier',
41     name varchar(64) unique key comment 'name of the carrier',
42     email_pattern varchar(255) not null comment 'sprintf pattern for making an email address from a phone number',
43     created datetime not null comment 'date this record was created',
44     modified timestamp comment 'date this record was modified'
45 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
46
47 /* local users */
48
49 create table user (
50
51     id integer primary key comment 'foreign key to profile table' references profile (id),
52     nickname varchar(64) unique key comment 'nickname or username, duped in profile',
53     password varchar(255) comment 'salted password, can be null for OpenID users',
54     email varchar(255) unique key comment 'email address for password recovery etc.',
55     incomingemail varchar(255) unique key comment 'email address for post-by-email',
56     emailnotifysub tinyint default 1 comment 'Notify by email of subscriptions',
57     emailnotifyfav tinyint default 1 comment 'Notify by email of favorites',
58     emailnotifynudge tinyint default 1 comment 'Notify by email of nudges',
59     emailnotifymsg tinyint default 1 comment 'Notify by email of direct messages',
60     emailnotifyattn tinyint default 1 comment 'Notify by email of @-replies',
61     emailmicroid tinyint default 1 comment 'whether to publish email microid',
62     language varchar(50) comment 'preferred language',
63     timezone varchar(50) comment 'timezone',
64     emailpost tinyint default 1 comment 'Post by email',
65     sms varchar(64) unique key comment 'sms phone number',
66     carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
67     smsnotify tinyint default 0 comment 'whether to send notices to SMS',
68     smsreplies tinyint default 0 comment 'whether to send notices to SMS on replies',
69     smsemail varchar(255) comment 'built from sms and carrier',
70     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
71     autosubscribe tinyint default 0 comment 'automatically subscribe to users who subscribe to us',
72     urlshorteningservice varchar(50) default 'ur1.ca' comment 'service to use for auto-shortening URLs',
73     inboxed tinyint default 0 comment 'has an inbox been created for this user?',
74     design_id integer comment 'id of a design' references design(id),
75     viewdesigns tinyint default 1 comment 'whether to view user-provided designs',
76
77     created datetime not null comment 'date this record was created',
78     modified timestamp comment 'date this record was modified',
79
80     index user_smsemail_idx (smsemail)
81 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
82
83 /* remote people */
84
85 create table remote_profile (
86     id integer primary key comment 'foreign key to profile table' references profile (id),
87     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
88     postnoticeurl varchar(255) comment 'URL we use for posting notices',
89     updateprofileurl varchar(255) comment 'URL we use for updates to this profile',
90     created datetime not null comment 'date this record was created',
91     modified timestamp comment 'date this record was modified'
92 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
93
94 create table subscription (
95     subscriber integer not null comment 'profile listening',
96     subscribed integer not null comment 'profile being listened to',
97     jabber tinyint default 1 comment 'deliver jabber messages',
98     sms tinyint default 1 comment 'deliver sms messages',
99     token varchar(255) comment 'authorization token',
100     secret varchar(255) comment 'token secret',
101     created datetime not null comment 'date this record was created',
102     modified timestamp comment 'date this record was modified',
103
104     constraint primary key (subscriber, subscribed),
105     index subscription_subscriber_idx (subscriber, created),
106     index subscription_subscribed_idx (subscribed, created),
107     index subscription_token_idx (token)
108 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
109
110 create table notice (
111     id integer auto_increment primary key comment 'unique identifier',
112     profile_id integer not null comment 'who made the update' references profile (id),
113     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
114     content text comment 'update content',
115     rendered text comment 'HTML version of the content',
116     url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
117     created datetime not null comment 'date this record was created',
118     modified timestamp comment 'date this record was modified',
119     reply_to integer comment 'notice replied to (usually a guess)' references notice (id),
120     is_local tinyint default 0 comment 'notice was generated by a user',
121     source varchar(32) comment 'source of comment, like "web", "im", or "clientname"',
122     conversation integer comment 'id of root notice in this conversation' references notice (id),
123     lat decimal(10,7) comment 'latitude',
124     lon decimal(10,7) comment 'longitude',
125     location_id integer comment 'location id if possible',
126     location_ns integer comment 'namespace for location',
127     repeat_of integer comment 'notice this is a repeat of' references notice (id),
128
129     index notice_profile_id_idx (profile_id,created,id),
130     index notice_conversation_idx (conversation),
131     index notice_created_idx (created),
132     index notice_replyto_idx (reply_to),
133     index notice_repeatof_idx (repeat_of),
134     FULLTEXT(content)
135 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
136
137 create table notice_source (
138      code varchar(32) primary key not null comment 'source code',
139      name varchar(255) not null comment 'name of the source',
140      url varchar(255) not null comment 'url to link to',
141      created datetime not null comment 'date this record was created',
142      modified timestamp comment 'date this record was modified'
143 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
144
145 create table reply (
146     notice_id integer not null comment 'notice that is the reply' references notice (id),
147     profile_id integer not null comment 'profile replied to' references profile (id),
148     modified timestamp not null comment 'date this record was modified',
149     replied_id integer comment 'notice replied to (not used, see notice.reply_to)',
150
151     constraint primary key (notice_id, profile_id),
152     index reply_notice_id_idx (notice_id),
153     index reply_profile_id_idx (profile_id),
154     index reply_replied_id_idx (replied_id)
155
156 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
157
158 create table fave (
159     notice_id integer not null comment 'notice that is the favorite' references notice (id),
160     user_id integer not null comment 'user who likes this notice' references user (id),
161     modified timestamp not null comment 'date this record was modified',
162
163     constraint primary key (notice_id, user_id),
164     index fave_notice_id_idx (notice_id),
165     index fave_user_id_idx (user_id,modified),
166     index fave_modified_idx (modified)
167
168 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
169
170 /* tables for OAuth */
171
172 create table consumer (
173     consumer_key varchar(255) primary key comment 'unique identifier, root URL',
174     consumer_secret varchar(255) not null comment 'secret value',
175     seed char(32) not null comment 'seed for new tokens by this consumer',
176
177     created datetime not null comment 'date this record was created',
178     modified timestamp comment 'date this record was modified'
179 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
180
181 create table token (
182     consumer_key varchar(255) not null comment 'unique identifier, root URL' references consumer (consumer_key),
183     tok char(32) not null comment 'identifying value',
184     secret char(32) not null comment 'secret value',
185     type tinyint not null default 0 comment 'request or access',
186     state tinyint default 0 comment 'for requests, 0 = initial, 1 = authorized, 2 = used',
187     verifier varchar(255) comment 'verifier string for OAuth 1.0a',
188     verified_callback varchar(255) comment 'verified callback URL for OAuth 1.0a',
189
190     created datetime not null comment 'date this record was created',
191     modified timestamp comment 'date this record was modified',
192
193     constraint primary key (consumer_key, tok)
194 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
195
196 create table nonce (
197     consumer_key varchar(255) not null comment 'unique identifier, root URL',
198     tok char(32) null comment 'buggy old value, ignored',
199     nonce char(32) not null comment 'nonce',
200     ts datetime not null comment 'timestamp sent',
201
202     created datetime not null comment 'date this record was created',
203     modified timestamp comment 'date this record was modified',
204
205     constraint primary key (consumer_key, ts, nonce)
206 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
207
208 create table oauth_application (
209     id integer auto_increment primary key comment 'unique identifier',
210     owner integer not null comment 'owner of the application' references profile (id),
211     consumer_key varchar(255) not null comment 'application consumer key' references consumer (consumer_key),
212     name varchar(255) not null unique key comment 'name of the application',
213     description varchar(255) comment 'description of the application',
214     icon varchar(255) not null comment 'application icon',
215     source_url varchar(255) comment 'application homepage - used for source link',
216     organization varchar(255) comment 'name of the organization running the application',
217     homepage varchar(255) comment 'homepage for the organization',
218     callback_url varchar(255) comment 'url to redirect to after authentication',
219     type tinyint default 0 comment 'type of app, 1 = browser, 2 = desktop',
220     access_type tinyint default 0 comment 'default access type, bit 1 = read, bit 2 = write',
221     created datetime not null comment 'date this record was created',
222     modified timestamp comment 'date this record was modified'
223 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
224
225 create table oauth_application_user (
226     profile_id integer not null comment 'user of the application' references profile (id),
227     application_id integer not null comment 'id of the application' references oauth_application (id),
228     access_type tinyint default 0 comment 'access type, bit 1 = read, bit 2 = write',
229     token varchar(255) comment 'request or access token',
230     created datetime not null comment 'date this record was created',
231     modified timestamp comment 'date this record was modified',
232     constraint primary key (profile_id, application_id)
233 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
234
235 /* These are used by JanRain OpenID library */
236
237 create table oid_associations (
238     server_url BLOB,
239     handle VARCHAR(255) character set latin1,
240     secret BLOB,
241     issued INTEGER,
242     lifetime INTEGER,
243     assoc_type VARCHAR(64),
244     PRIMARY KEY (server_url(255), handle)
245 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
246
247 create table oid_nonces (
248     server_url VARCHAR(2047),
249     timestamp INTEGER,
250     salt CHAR(40),
251     UNIQUE (server_url(255), timestamp, salt)
252 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
253
254 create table confirm_address (
255     code varchar(32) not null primary key comment 'good random code',
256     user_id integer not null comment 'user who requested confirmation' references user (id),
257     address varchar(255) not null comment 'address (email, xmpp, SMS, etc.)',
258     address_extra varchar(255) not null comment 'carrier ID, for SMS',
259     address_type varchar(8) not null comment 'address type ("email", "xmpp", "sms")',
260     claimed datetime comment 'date this was claimed for queueing',
261     sent datetime comment 'date this was sent for queueing',
262     modified timestamp comment 'date this record was modified'
263 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
264
265 create table remember_me (
266     code varchar(32) not null primary key comment 'good random code',
267     user_id integer not null comment 'user who is logged in' references user (id),
268     modified timestamp comment 'date this record was modified'
269 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
270
271 create table queue_item (
272     id integer auto_increment primary key comment 'unique identifier',
273     frame blob not null comment 'data: object reference or opaque string',
274     transport varchar(8) not null comment 'queue for what? "email", "xmpp", "sms", "irc", ...',
275     created datetime not null comment 'date this record was created',
276     claimed datetime comment 'date this item was claimed',
277
278     index queue_item_created_idx (created)
279
280 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
281
282 /* Hash tags */
283 create table notice_tag (
284     tag varchar( 64 ) not null comment 'hash tag associated with this notice',
285     notice_id integer not null comment 'notice tagged' references notice (id),
286     created datetime not null comment 'date this record was created',
287
288     constraint primary key (tag, notice_id),
289     index notice_tag_created_idx (created),
290     index notice_tag_notice_id_idx (notice_id)
291 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
292
293 /* Synching with foreign services */
294
295 create table foreign_service (
296      id int not null primary key comment 'numeric key for service',
297      name varchar(32) not null unique key comment 'name of the service',
298      description varchar(255) comment 'description',
299      created datetime not null comment 'date this record was created',
300      modified timestamp comment 'date this record was modified'
301 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
302
303 create table foreign_user (
304      id bigint not null comment 'unique numeric key on foreign service',
305      service int not null comment 'foreign key to service' references foreign_service(id),
306      uri varchar(255) not null unique key comment 'identifying URI',
307      nickname varchar(255) comment 'nickname on foreign service',
308      created datetime not null comment 'date this record was created',
309      modified timestamp comment 'date this record was modified',
310
311      constraint primary key (id, service)
312 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
313
314 create table foreign_link (
315      user_id int comment 'link to user on this system, if exists' references user (id),
316      foreign_id bigint unsigned comment 'link to user on foreign service, if exists' references foreign_user(id),
317      service int not null comment 'foreign key to service' references foreign_service(id),
318      credentials varchar(255) comment 'authc credentials, typically a password',
319      noticesync tinyint not null default 1 comment 'notice synchronization, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies',
320      friendsync tinyint not null default 2 comment 'friend synchronization, bit 1 = sync outgoing, bit 2 = sync incoming',
321      profilesync tinyint not null default 1 comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming',
322      last_noticesync datetime default null comment 'last time notices were imported',
323      last_friendsync datetime default null comment 'last time friends were imported',
324      created datetime not null comment 'date this record was created',
325      modified timestamp comment 'date this record was modified',
326
327      constraint primary key (user_id, foreign_id, service),
328      index foreign_user_user_id_idx (user_id)
329 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
330
331 create table foreign_subscription (
332      service int not null comment 'service where relationship happens' references foreign_service(id),
333      subscriber int not null comment 'subscriber on foreign service' references foreign_user (id),
334      subscribed int not null comment 'subscribed user' references foreign_user (id),
335      created datetime not null comment 'date this record was created',
336
337      constraint primary key (service, subscriber, subscribed),
338      index foreign_subscription_subscriber_idx (subscriber),
339      index foreign_subscription_subscribed_idx (subscribed)
340 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
341
342 create table invitation (
343      code varchar(32) not null primary key comment 'random code for an invitation',
344      user_id int not null comment 'who sent the invitation' references user (id),
345      address varchar(255) not null comment 'invitation sent to',
346      address_type varchar(8) not null comment 'address type ("email", "xmpp", "sms")',
347      created datetime not null comment 'date this record was created',
348
349      index invitation_address_idx (address, address_type),
350      index invitation_user_id_idx (user_id)
351 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
352
353 create table message (
354     id integer auto_increment primary key comment 'unique identifier',
355     uri varchar(255) unique key comment 'universally unique identifier',
356     from_profile integer not null comment 'who the message is from' references profile (id),
357     to_profile integer not null comment 'who the message is to' references profile (id),
358     content text comment 'message content',
359     rendered text comment 'HTML version of the content',
360     url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
361     created datetime not null comment 'date this record was created',
362     modified timestamp comment 'date this record was modified',
363     source varchar(32) comment 'source of comment, like "web", "im", or "clientname"',
364
365     index message_from_idx (from_profile),
366     index message_to_idx (to_profile),
367     index message_created_idx (created)
368 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
369
370 create table notice_inbox (
371     user_id integer not null comment 'user receiving the message' references user (id),
372     notice_id integer not null comment 'notice received' references notice (id),
373     created datetime not null comment 'date the notice was created',
374     source tinyint default 1 comment 'reason it is in the inbox, 1=subscription',
375
376     constraint primary key (user_id, notice_id),
377     index notice_inbox_notice_id_idx (notice_id)
378 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
379
380 create table profile_tag (
381    tagger integer not null comment 'user making the tag' references user (id),
382    tagged integer not null comment 'profile tagged' references profile (id),
383    tag varchar(64) not null comment 'hash tag associated with this notice',
384    modified timestamp comment 'date the tag was added',
385
386    constraint primary key (tagger, tagged, tag),
387    index profile_tag_modified_idx (modified),
388    index profile_tag_tagger_tag_idx (tagger, tag),
389    index profile_tag_tagged_idx (tagged)
390 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
391
392 create table profile_block (
393    blocker integer not null comment 'user making the block' references user (id),
394    blocked integer not null comment 'profile that is blocked' references profile (id),
395    modified timestamp comment 'date of blocking',
396
397    constraint primary key (blocker, blocked)
398
399 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
400
401 create table user_group (
402     id integer auto_increment primary key comment 'unique identifier',
403
404     nickname varchar(64) comment 'nickname for addressing',
405     fullname varchar(255) comment 'display name',
406     homepage varchar(255) comment 'URL, cached so we dont regenerate',
407     description text comment 'group description',
408     location varchar(255) comment 'related physical location, if any',
409
410     original_logo varchar(255) comment 'original size logo',
411     homepage_logo varchar(255) comment 'homepage (profile) size logo',
412     stream_logo varchar(255) comment 'stream-sized logo',
413     mini_logo varchar(255) comment 'mini logo',
414     design_id integer comment 'id of a design' references design(id),
415
416     created datetime not null comment 'date this record was created',
417     modified timestamp comment 'date this record was modified',
418
419     uri varchar(255) unique key comment 'universal identifier',
420     mainpage varchar(255) comment 'page for group info to link to',
421
422     index user_group_nickname_idx (nickname)
423
424 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
425
426 create table group_member (
427     group_id integer not null comment 'foreign key to user_group' references user_group (id),
428     profile_id integer not null comment 'foreign key to profile table' references profile (id),
429     is_admin boolean default false comment 'is this user an admin?',
430
431     created datetime not null comment 'date this record was created',
432     modified timestamp comment 'date this record was modified',
433
434     constraint primary key (group_id, profile_id),
435     index group_member_profile_id_idx (profile_id),
436     index group_member_created_idx (created)
437
438 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
439
440 create table related_group (
441     group_id integer not null comment 'foreign key to user_group' references user_group (id),
442     related_group_id integer not null comment 'foreign key to user_group' references user_group (id),
443
444     created datetime not null comment 'date this record was created',
445
446     constraint primary key (group_id, related_group_id)
447
448 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
449
450 create table group_inbox (
451     group_id integer not null comment 'group receiving the message' references user_group (id),
452     notice_id integer not null comment 'notice received' references notice (id),
453     created datetime not null comment 'date the notice was created',
454
455     constraint primary key (group_id, notice_id),
456     index group_inbox_created_idx (created),
457     index group_inbox_notice_id_idx (notice_id)
458
459 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
460
461 create table file (
462
463     id integer primary key auto_increment,
464     url varchar(255) comment 'destination URL after following redirections',
465     mimetype varchar(50) comment 'mime type of resource',
466     size integer comment 'size of resource when available',
467     title varchar(255) comment 'title of resource when available',
468     date integer(11) comment 'date of resource according to http query',
469     protected integer(1) comment 'true when URL is private (needs login)',
470     filename varchar(255) comment 'if a local file, name of the file',
471
472     modified timestamp comment 'date this record was modified',
473
474     unique(url)
475 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
476
477 create table file_oembed (
478     file_id integer primary key comment 'oEmbed for that URL/file' references file (id),
479     version varchar(20) comment 'oEmbed spec. version',
480     type varchar(20) comment 'oEmbed type: photo, video, link, rich',
481     mimetype varchar(50) comment 'mime type of resource',
482     provider varchar(50) comment 'name of this oEmbed provider',
483     provider_url varchar(255) comment 'URL of this oEmbed provider',
484     width integer comment 'width of oEmbed resource when available',
485     height integer comment 'height of oEmbed resource when available',
486     html text comment 'html representation of this oEmbed resource when applicable',
487     title varchar(255) comment 'title of oEmbed resource when available',
488     author_name varchar(50) comment 'author name for this oEmbed resource',
489     author_url varchar(255) comment 'author URL for this oEmbed resource',
490     url varchar(255) comment 'URL for this oEmbed resource when applicable (photo, link)',
491     modified timestamp comment 'date this record was modified'
492
493 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
494
495 create table file_redirection (
496
497     url varchar(255) primary key comment 'short URL (or any other kind of redirect) for file (id)',
498     file_id integer comment 'short URL for what URL/file' references file (id),
499     redirections integer comment 'redirect count',
500     httpcode integer comment 'HTTP status code (20x, 30x, etc.)',
501     modified timestamp comment 'date this record was modified'
502
503 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
504
505 create table file_thumbnail (
506
507     file_id integer primary key comment 'thumbnail for what URL/file' references file (id),
508     url varchar(255) comment 'URL of thumbnail',
509     width integer comment 'width of thumbnail',
510     height integer comment 'height of thumbnail',
511     modified timestamp comment 'date this record was modified',
512
513     unique(url)
514 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
515
516 create table file_to_post (
517
518     file_id integer comment 'id of URL/file' references file (id),
519     post_id integer comment 'id of the notice it belongs to' references notice (id),
520     modified timestamp comment 'date this record was modified',
521
522     constraint primary key (file_id, post_id),
523     index post_id_idx (post_id)
524
525 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
526
527 create table design (
528     id integer primary key auto_increment comment 'design ID',
529     backgroundcolor integer comment 'main background color',
530     contentcolor integer comment 'content area background color',
531     sidebarcolor integer comment 'sidebar background color',
532     textcolor integer comment 'text color',
533     linkcolor integer comment 'link color',
534     backgroundimage varchar(255) comment 'background image, if any',
535     disposition tinyint default 1 comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'
536 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
537
538 create table group_block (
539    group_id integer not null comment 'group profile is blocked from' references user_group (id),
540    blocked integer not null comment 'profile that is blocked' references profile (id),
541    blocker integer not null comment 'user making the block' references user (id),
542    modified timestamp comment 'date of blocking',
543
544    constraint primary key (group_id, blocked)
545
546 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
547
548 create table group_alias (
549
550    alias varchar(64) primary key comment 'additional nickname for the group',
551    group_id integer not null comment 'group profile is blocked from' references user_group (id),
552    modified timestamp comment 'date alias was created',
553
554    index group_alias_group_id_idx (group_id)
555
556 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
557
558 create table session (
559
560     id varchar(32) primary key comment 'session ID',
561     session_data text comment 'session data',
562     created datetime not null comment 'date this record was created',
563     modified timestamp comment 'date this record was modified',
564
565     index session_modified_idx (modified)
566
567 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
568
569 create table deleted_notice (
570
571     id integer primary key comment 'identity of notice',
572     profile_id integer not null comment 'author of the notice',
573     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
574     created datetime not null comment 'date the notice record was created',
575     deleted datetime not null comment 'date the notice record was created',
576
577     index deleted_notice_profile_id_idx (profile_id)
578
579 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
580
581 create table config (
582
583     section varchar(32) comment 'configuration section',
584     setting varchar(32) comment 'configuration setting',
585     value varchar(255) comment 'configuration value',
586
587     constraint primary key (section, setting)
588
589 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
590
591 create table profile_role (
592
593     profile_id integer not null comment 'account having the role' references profile (id),
594     role    varchar(32) not null comment 'string representing the role',
595     created datetime not null comment 'date the role was granted',
596
597     constraint primary key (profile_id, role)
598
599 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
600
601 create table location_namespace (
602
603     id integer primary key comment 'identity for this namespace',
604     description varchar(255) comment 'description of the namespace',
605     created datetime not null comment 'date the record was created',
606     modified timestamp comment 'date this record was modified'
607
608 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
609
610 create table login_token (
611     user_id integer not null comment 'user owning this token' references user (id),
612     token char(32) not null comment 'token useable for logging in',
613     created datetime not null comment 'date this record was created',
614     modified timestamp comment 'date this record was modified',
615
616     constraint primary key (user_id)
617 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
618
619 create table user_location_prefs (
620     user_id integer not null comment 'user who has the preference' references user (id),
621     share_location tinyint default 1 comment 'Whether to share location data',
622     created datetime not null comment 'date this record was created',
623     modified timestamp comment 'date this record was modified',
624
625     constraint primary key (user_id)
626 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
627
628 create table inbox (
629
630     user_id integer not null comment 'user receiving the notice' references user (id),
631     notice_ids blob comment 'packed list of notice ids',
632
633     constraint primary key (user_id)
634
635 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
636
637 create table user_im_prefs (
638     user_id integer not null comment 'user' references user (id),
639     screenname varchar(255) not null comment 'screenname on this service',
640     transport varchar(255) not null comment 'transport (ex xmpp, aim)',
641     notify tinyint(1) not null default 0 comment 'Notify when a new notice is sent',
642     replies tinyint(1) not null default 0 comment 'Send replies  from people not subscribed to',
643     microid tinyint(1) not null default 1 comment 'Publish a MicroID',
644     updatefrompresence tinyint(1) not null default 0 comment 'Send replies  from people not subscribed to.',
645     created timestamp not null DEFAULT CURRENT_TIMESTAMP comment 'date this record was created',
646     modified timestamp comment 'date this record was modified',
647
648     constraint primary key (user_id, transport),
649     constraint unique key `transport_screenname_key` ( `transport` , `screenname` )
650 );
651
652 create table conversation (
653     id integer auto_increment primary key comment 'unique identifier',
654     uri varchar(225) unique comment 'URI of the conversation',
655     created datetime not null comment 'date this record was created',
656     modified timestamp comment 'date this record was modified'
657 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
658
659 create table local_group (
660
661    group_id integer primary key comment 'group represented' references user_group (id),
662    nickname varchar(64) unique key comment 'group represented',
663
664    created datetime not null comment 'date this record was created',
665    modified timestamp comment 'date this record was modified'
666
667 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;