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