1 /* local and remote users have profiles */
2 create sequence profile_seq;
4 id bigint default nextval('profile_seq') primary key /* comment 'unique identifier' */,
5 nickname varchar(64) not null /* comment 'nickname or username' */,
6 fullname varchar(255) /* comment 'display name' */,
7 profileurl varchar(255) /* comment 'URL, cached so we dont regenerate' */,
8 homepage varchar(255) /* comment 'identifying URL' */,
9 bio varchar(140) /* comment 'descriptive biography' */,
10 location varchar(255) /* comment 'physical location' */,
11 lat decimal(10,7) /* comment 'latitude'*/ ,
12 lon decimal(10,7) /* comment 'longitude'*/ ,
13 location_id integer /* comment 'location id if possible'*/ ,
14 location_ns integer /* comment 'namespace for location'*/ ,
15 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
16 modified timestamp /* comment 'date this record was modified' */,
20 create index profile_nickname_idx on profile using btree(nickname);
23 profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id) ,
24 original integer default 0 /* comment 'uploaded by user or generated?' */,
25 width integer not null /* comment 'image width' */,
26 height integer not null /* comment 'image height' */,
27 mediatype varchar(32) not null /* comment 'file type' */,
28 filename varchar(255) null /* comment 'local filename, if local' */,
29 url varchar(255) unique /* comment 'avatar location' */,
30 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
31 modified timestamp /* comment 'date this record was modified' */,
33 primary key(profile_id, width, height)
35 create index avatar_profile_id_idx on avatar using btree(profile_id);
37 create sequence sms_carrier_seq;
38 create table sms_carrier (
39 id bigint default nextval('sms_carrier_seq') primary key /* comment 'primary key for SMS carrier' */,
40 name varchar(64) unique /* comment 'name of the carrier' */,
41 email_pattern varchar(255) not null /* comment 'sprintf pattern for making an email address from a phone number' */,
42 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
43 modified timestamp /* comment 'date this record was modified ' */
46 create sequence design_seq;
48 id bigint default nextval('design_seq') /* comment 'design ID'*/,
49 backgroundcolor integer /* comment 'main background color'*/ ,
50 contentcolor integer /*comment 'content area background color'*/ ,
51 sidebarcolor integer /*comment 'sidebar background color'*/ ,
52 textcolor integer /*comment 'text color'*/ ,
53 linkcolor integer /*comment 'link color'*/,
54 backgroundimage varchar(255) /*comment 'background image, if any'*/,
55 disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/,
62 id integer primary key /* comment 'foreign key to profile table' */ references profile (id) ,
63 nickname varchar(64) unique /* comment 'nickname or username, duped in profile' */,
64 password varchar(255) /* comment 'salted password, can be null for OpenID users' */,
65 email varchar(255) unique /* comment 'email address for password recovery etc.' */,
66 incomingemail varchar(255) unique /* comment 'email address for post-by-email' */,
67 emailnotifysub integer default 1 /* comment 'Notify by email of subscriptions' */,
68 emailnotifyfav integer default 1 /* comment 'Notify by email of favorites' */,
69 emailnotifynudge integer default 1 /* comment 'Notify by email of nudges' */,
70 emailnotifymsg integer default 1 /* comment 'Notify by email of direct messages' */,
71 emailnotifyattn integer default 1 /* command 'Notify by email of @-replies' */,
72 emailmicroid integer default 1 /* comment 'whether to publish email microid' */,
73 language varchar(50) /* comment 'preferred language' */,
74 timezone varchar(50) /* comment 'timezone' */,
75 emailpost integer default 1 /* comment 'Post by email' */,
76 jabber varchar(255) unique /* comment 'jabber ID for notices' */,
77 jabbernotify integer default 0 /* comment 'whether to send notices to jabber' */,
78 jabberreplies integer default 0 /* comment 'whether to send notices to jabber on replies' */,
79 jabbermicroid integer default 1 /* comment 'whether to publish xmpp microid' */,
80 updatefrompresence integer default 0 /* comment 'whether to record updates from Jabber presence notices' */,
81 sms varchar(64) unique /* comment 'sms phone number' */,
82 carrier integer /* comment 'foreign key to sms_carrier' */ references sms_carrier (id) ,
83 smsnotify integer default 0 /* comment 'whether to send notices to SMS' */,
84 smsreplies integer default 0 /* comment 'whether to send notices to SMS on replies' */,
85 smsemail varchar(255) /* comment 'built from sms and carrier' */,
86 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
87 autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */,
88 urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */,
89 inboxed integer default 0 /* comment 'has an inbox been created for this user?' */,
90 design_id integer /* comment 'id of a design' */references design(id),
91 viewdesigns integer default 1 /* comment 'whether to view user-provided designs'*/,
92 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
93 modified timestamp /* comment 'date this record was modified' */
96 create index user_smsemail_idx on "user" using btree(smsemail);
100 create table remote_profile (
101 id integer primary key /* comment 'foreign key to profile table' */ references profile (id) ,
102 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
103 postnoticeurl varchar(255) /* comment 'URL we use for posting notices' */,
104 updateprofileurl varchar(255) /* comment 'URL we use for updates to this profile' */,
105 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
106 modified timestamp /* comment 'date this record was modified' */
109 create table subscription (
110 subscriber integer not null /* comment 'profile listening' */,
111 subscribed integer not null /* comment 'profile being listened to' */,
112 jabber integer default 1 /* comment 'deliver jabber messages' */,
113 sms integer default 1 /* comment 'deliver sms messages' */,
114 token varchar(255) /* comment 'authorization token' */,
115 secret varchar(255) /* comment 'token secret' */,
116 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
117 modified timestamp /* comment 'date this record was modified' */,
119 primary key (subscriber, subscribed)
121 create index subscription_subscriber_idx on subscription using btree(subscriber,created);
122 create index subscription_subscribed_idx on subscription using btree(subscribed,created);
124 create sequence notice_seq;
125 create table notice (
127 id bigint default nextval('notice_seq') primary key /* comment 'unique identifier' */,
128 profile_id integer not null /* comment 'who made the update' */ references profile (id) ,
129 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
130 content varchar(140) /* comment 'update content' */,
131 rendered text /* comment 'HTML version of the content' */,
132 url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,
133 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
134 modified timestamp /* comment 'date this record was modified' */,
135 reply_to integer /* comment 'notice replied to (usually a guess)' */ references notice (id) ,
136 is_local integer default 0 /* comment 'notice was generated by a user' */,
137 source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */,
138 conversation integer /*id of root notice in this conversation' */ references notice (id),
139 location varchar(255) /* comment 'physical location' */,
140 lat decimal(10,7) /* comment 'latitude'*/ ,
141 lon decimal(10,7) /* comment 'longitude'*/ ,
142 location_id integer /* comment 'location id if possible'*/ ,
143 location_ns integer /* comment 'namespace for location'*/ ,
144 repeat_of integer /* comment 'notice this is a repeat of' */ references notice (id)
146 /* FULLTEXT(content) */
149 create index notice_profile_id_idx on notice using btree(profile_id,created,id);
150 create index notice_created_idx on notice using btree(created);
152 create table notice_source (
153 code varchar(32) primary key not null /* comment 'source code' */,
154 name varchar(255) not null /* comment 'name of the source' */,
155 url varchar(255) not null /* comment 'url to link to' */,
156 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
157 modified timestamp /* comment 'date this record was modified' */
162 notice_id integer not null /* comment 'notice that is the reply' */ references notice (id) ,
163 profile_id integer not null /* comment 'profile replied to' */ references profile (id) ,
164 modified timestamp /* comment 'date this record was modified' */,
165 replied_id integer /* comment 'notice replied to (not used, see notice.reply_to)' */,
167 primary key (notice_id, profile_id)
170 create index reply_notice_id_idx on reply using btree(notice_id);
171 create index reply_profile_id_idx on reply using btree(profile_id);
172 create index reply_replied_id_idx on reply using btree(replied_id);
176 notice_id integer not null /* comment 'notice that is the favorite' */ references notice (id),
177 user_id integer not null /* comment 'user who likes this notice' */ references "user" (id) ,
178 modified timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was modified' */,
179 primary key (notice_id, user_id)
182 create index fave_notice_id_idx on fave using btree(notice_id);
183 create index fave_user_id_idx on fave using btree(user_id,modified);
184 create index fave_modified_idx on fave using btree(modified);
186 /* tables for OAuth */
188 create table consumer (
189 consumer_key varchar(255) primary key /* comment 'unique identifier, root URL' */,
190 consumer_secret varchar(255) not null /* comment 'secret value', */,
191 seed char(32) not null /* comment 'seed for new tokens by this consumer' */,
193 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
194 modified timestamp /* comment 'date this record was modified' */
198 consumer_key varchar(255) not null /* comment 'unique identifier, root URL' */ references consumer (consumer_key),
199 tok char(32) not null /* comment 'identifying value' */,
200 secret char(32) not null /* comment 'secret value' */,
201 type integer not null default 0 /* comment 'request or access' */,
202 state integer default 0 /* comment 'for requests 0 = initial, 1 = authorized, 2 = used' */,
204 verifier varchar(255) /*comment 'verifier string for OAuth 1.0a'*/,
205 verified_callback varchar(255) /*comment 'verified callback URL for OAuth 1.0a'*/,
207 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
208 modified timestamp /* comment 'date this record was modified' */,
210 primary key (consumer_key, tok)
214 consumer_key varchar(255) not null /* comment 'unique identifier, root URL' */,
215 tok char(32) /* comment 'buggy old value, ignored' */,
216 nonce char(32) null /* comment 'buggy old value, ignored */,
217 ts integer not null /* comment 'timestamp sent' values are epoch, and only used internally */,
219 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
220 modified timestamp /* comment 'date this record was modified' */,
222 primary key (consumer_key, ts, nonce)
225 create sequence oauth_application_seq;
226 create table oauth_application (
227 id bigint default nextval('oauth_application_seq') primary key /* comment 'unique identifier' */,
228 owner integer not null /* comment 'owner of the application' */ references profile (id),
229 consumer_key varchar(255) not null /* comment 'application consumer key' */ references consumer (consumer_key),
230 name varchar(255) unique not null /* comment 'name of the application' */,
231 description varchar(255) /* comment 'description of the application' */,
232 icon varchar(255) not null /* comment 'application icon' */,
233 source_url varchar(255) /* comment 'application homepage - used for source link' */,
234 organization varchar(255) /* comment 'name of the organization running the application' */,
235 homepage varchar(255) /* comment 'homepage for the organization' */,
236 callback_url varchar(255) /* comment 'url to redirect to after authentication' */,
237 "type" integer default 0 /* comment 'type of app, 1 = browser, 2 = desktop' */,
238 access_type integer default 0 /* comment 'default access type, bit 1 = read, bit 2 = write' */,
239 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
240 modified timestamp /* comment 'date this record was modified' */
243 create table oauth_application_user (
244 profile_id integer not null /* 'user of the application' */ references profile (id),
245 application_id integer not null /* 'id of the application' */ references oauth_application (id),
246 access_type integer default 0 /* 'access type, bit 1 = read, bit 2 = write' */,
247 token varchar(255) /* 'request or access token' */,
248 created timestamp not null default CURRENT_TIMESTAMP /* 'date this record was created' */,
249 modified timestamp /* 'date this record was modified' */,
250 primary key (profile_id, application_id)
253 /* These are used by JanRain OpenID library */
255 create table oid_associations (
256 server_url varchar(2047),
261 assoc_type varchar(64),
262 primary key (server_url, handle)
265 create table oid_nonces (
266 server_url varchar(2047),
269 unique (server_url, "timestamp", salt)
272 create table confirm_address (
273 code varchar(32) not null primary key /* comment 'good random code' */,
274 user_id integer not null /* comment 'user who requested confirmation' */ references "user" (id),
275 address varchar(255) not null /* comment 'address (email, Jabber, SMS, etc.)' */,
276 address_extra varchar(255) not null default '' /* comment 'carrier ID, for SMS' */,
277 address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms")' */,
278 claimed timestamp /* comment 'date this was claimed for queueing' */,
279 sent timestamp /* comment 'date this was sent for queueing' */,
280 modified timestamp /* comment 'date this record was modified' */
283 create table remember_me (
284 code varchar(32) not null primary key /* comment 'good random code' */,
285 user_id integer not null /* comment 'user who is logged in' */ references "user" (id),
286 modified timestamp /* comment 'date this record was modified' */
289 create table queue_item (
291 notice_id integer not null /* comment 'notice queued' */ references notice (id) ,
292 transport varchar(8) not null /* comment 'queue for what? "email", "jabber", "sms", "irc", ...' */,
293 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
294 claimed timestamp /* comment 'date this item was claimed' */,
296 primary key (notice_id, transport)
299 create index queue_item_created_idx on queue_item using btree(created);
302 create table notice_tag (
303 tag varchar( 64 ) not null /* comment 'hash tag associated with this notice' */,
304 notice_id integer not null /* comment 'notice tagged' */ references notice (id) ,
305 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
307 primary key (tag, notice_id)
309 create index notice_tag_created_idx on notice_tag using btree(created);
311 /* Synching with foreign services */
313 create table foreign_service (
314 id int not null primary key /* comment 'numeric key for service' */,
315 name varchar(32) not null unique /* comment 'name of the service' */,
316 description varchar(255) /* comment 'description' */,
317 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
318 modified timestamp /* comment 'date this record was modified' */
321 create table foreign_user (
322 id int not null unique /* comment 'unique numeric key on foreign service' */,
323 service int not null /* comment 'foreign key to service' */ references foreign_service(id) ,
324 uri varchar(255) not null unique /* comment 'identifying URI' */,
325 nickname varchar(255) /* comment 'nickname on foreign service' */,
326 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
327 modified timestamp /* comment 'date this record was modified' */,
329 primary key (id, service)
332 create table foreign_link (
333 user_id int /* comment 'link to user on this system, if exists' */ references "user" (id),
334 foreign_id int /* comment 'link' */ references foreign_user (id),
335 service int not null /* comment 'foreign key to service' */ references foreign_service (id),
336 credentials varchar(255) /* comment 'authc credentials, typically a password' */,
337 noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */,
338 friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */,
339 profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */,
340 last_noticesync timestamp default null /* comment 'last time notices were imported' */,
341 last_friendsync timestamp default null /* comment 'last time friends were imported' */,
342 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
343 modified timestamp /* comment 'date this record was modified' */,
345 primary key (user_id,foreign_id,service)
347 create index foreign_user_user_id_idx on foreign_link using btree(user_id);
349 create table foreign_subscription (
350 service int not null /* comment 'service where relationship happens' */ references foreign_service(id) ,
351 subscriber int not null /* comment 'subscriber on foreign service' */ ,
352 subscribed int not null /* comment 'subscribed user' */ ,
353 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
355 primary key (service, subscriber, subscribed)
357 create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber);
358 create index foreign_subscription_subscribed_idx on foreign_subscription using btree(subscribed);
360 create table invitation (
361 code varchar(32) not null primary key /* comment 'random code for an invitation' */,
362 user_id int not null /* comment 'who sent the invitation' */ references "user" (id),
363 address varchar(255) not null /* comment 'invitation sent to' */,
364 address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms") '*/,
365 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */
368 create index invitation_address_idx on invitation using btree(address,address_type);
369 create index invitation_user_id_idx on invitation using btree(user_id);
371 create sequence message_seq;
372 create table message (
374 id bigint default nextval('message_seq') primary key /* comment 'unique identifier' */,
375 uri varchar(255) unique /* comment 'universally unique identifier' */,
376 from_profile integer not null /* comment 'who the message is from' */ references profile (id),
377 to_profile integer not null /* comment 'who the message is to' */ references profile (id),
378 content varchar(140) /* comment 'message content' */,
379 rendered text /* comment 'HTML version of the content' */,
380 url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,
381 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
382 modified timestamp /* comment 'date this record was modified' */,
383 source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */
386 create index message_from_idx on message using btree(from_profile);
387 create index message_to_idx on message using btree(to_profile);
388 create index message_created_idx on message using btree(created);
390 create table notice_inbox (
392 user_id integer not null /* comment 'user receiving the message' */ references "user" (id),
393 notice_id integer not null /* comment 'notice received' */ references notice (id),
394 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
395 source integer default 1 /* comment 'reason it is in the inbox: 1=subscription' */,
397 primary key (user_id, notice_id)
399 create index notice_inbox_notice_id_idx on notice_inbox using btree(notice_id);
401 create table profile_tag (
402 tagger integer not null /* comment 'user making the tag' */ references "user" (id),
403 tagged integer not null /* comment 'profile tagged' */ references profile (id),
404 tag varchar(64) not null /* comment 'hash tag associated with this notice' */,
405 modified timestamp /* comment 'date the tag was added' */,
407 primary key (tagger, tagged, tag)
409 create index profile_tag_modified_idx on profile_tag using btree(modified);
410 create index profile_tag_tagger_tag_idx on profile_tag using btree(tagger,tag);
412 create table profile_block (
414 blocker integer not null /* comment 'user making the block' */ references "user" (id),
415 blocked integer not null /* comment 'profile that is blocked' */ references profile (id),
416 modified timestamp /* comment 'date of blocking' */,
418 primary key (blocker, blocked)
422 create sequence user_group_seq;
423 create table user_group (
425 id bigint default nextval('user_group_seq') primary key /* comment 'unique identifier' */,
427 nickname varchar(64) unique /* comment 'nickname for addressing' */,
428 fullname varchar(255) /* comment 'display name' */,
429 homepage varchar(255) /* comment 'URL, cached so we dont regenerate' */,
430 description varchar(140) /* comment 'descriptive biography' */,
431 location varchar(255) /* comment 'related physical location, if any' */,
433 original_logo varchar(255) /* comment 'original size logo' */,
434 homepage_logo varchar(255) /* comment 'homepage (profile) size logo' */,
435 stream_logo varchar(255) /* comment 'stream-sized logo' */,
436 mini_logo varchar(255) /* comment 'mini logo' */,
437 design_id integer /*comment 'id of a design' */ references design(id),
439 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
440 modified timestamp /* comment 'date this record was modified' */
443 create index user_group_nickname_idx on user_group using btree(nickname);
445 create table group_member (
447 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
448 profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id),
449 is_admin integer default 0 /* comment 'is this user an admin?' */,
451 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
452 modified timestamp /* comment 'date this record was modified' */,
454 primary key (group_id, profile_id)
457 create table related_group (
459 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id) ,
460 related_group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
462 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
464 primary key (group_id, related_group_id)
468 create table group_inbox (
469 group_id integer not null /* comment 'group receiving the message' references user_group (id) */,
470 notice_id integer not null /* comment 'notice received' references notice (id) */,
471 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
472 primary key (group_id, notice_id)
474 create index group_inbox_created_idx on group_inbox using btree(created);
476 /*attachments and URLs stuff */
477 create sequence file_seq;
479 id bigint default nextval('file_seq') primary key /* comment 'unique identifier' */,
480 url varchar(255) unique,
481 mimetype varchar(50),
486 filename text /* comment 'if a local file, name of the file' */,
487 modified timestamp default CURRENT_TIMESTAMP /* comment 'date this record was modified'*/
490 create sequence file_oembed_seq;
491 create table file_oembed (
492 file_id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
495 mimetype varchar(50),
496 provider varchar(50),
497 provider_url varchar(255),
502 author_name varchar(50),
503 author_url varchar(255),
507 create sequence file_redirection_seq;
508 create table file_redirection (
509 url varchar(255) primary key,
511 redirections integer,
515 create sequence file_thumbnail_seq;
516 create table file_thumbnail (
517 file_id bigint primary key,
518 url varchar(255) unique,
523 create sequence file_to_post_seq;
524 create table file_to_post (
528 primary key (file_id, post_id)
531 create table group_block (
532 group_id integer not null /* comment 'group profile is blocked from' */ references user_group (id),
533 blocked integer not null /* comment 'profile that is blocked' */references profile (id),
534 blocker integer not null /* comment 'user making the block'*/ references "user" (id),
535 modified timestamp /* comment 'date of blocking'*/ ,
537 primary key (group_id, blocked)
540 create table group_alias (
542 alias varchar(64) /* comment 'additional nickname for the group'*/ ,
543 group_id integer not null /* comment 'group profile is blocked from'*/ references user_group (id),
544 modified timestamp /* comment 'date alias was created'*/,
548 create index group_alias_group_id_idx on group_alias (group_id);
550 create table session (
552 id varchar(32) primary key /* comment 'session ID'*/,
553 session_data text /* comment 'session data'*/,
554 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
555 modified integer DEFAULT extract(epoch from CURRENT_TIMESTAMP) /* comment 'date this record was modified'*/
558 create index session_modified_idx on session (modified);
560 create table deleted_notice (
562 id integer primary key /* comment 'identity of notice'*/ ,
563 profile_id integer /* not null comment 'author of the notice'*/,
564 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI'*/,
565 created timestamp not null /* comment 'date the notice record was created'*/ ,
566 deleted timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date the notice record was created'*/
569 CREATE index deleted_notice_profile_id_idx on deleted_notice (profile_id);
571 /* Textsearch stuff */
573 create index textsearch_idx on profile using gist(textsearch);
574 create index noticecontent_idx on notice using gist(to_tsvector('english',content));
575 create trigger textsearchupdate before insert or update on profile for each row
576 execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);
578 create table config (
580 section varchar(32) /* comment 'configuration section'*/,
581 setting varchar(32) /* comment 'configuration setting'*/,
582 value varchar(255) /* comment 'configuration value'*/,
584 primary key (section, setting)
588 create table profile_role (
590 profile_id integer not null /* comment 'account having the role'*/ references profile (id),
591 role varchar(32) not null /* comment 'string representing the role'*/,
592 created timestamp /* not null comment 'date the role was granted'*/,
594 primary key (profile_id, role)
598 create table location_namespace (
600 id integer /*comment 'identity for this namespace'*/,
601 description text /* comment 'description of the namespace'*/ ,
602 created integer not null /*comment 'date the record was created*/ ,
603 /* modified timestamp comment 'date this record was modified',*/
608 create table login_token (
609 user_id integer not null /* comment 'user owning this token'*/ references "user" (id),
610 token char(32) not null /* comment 'token useable for logging in'*/,
611 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
612 modified timestamp /* comment 'date this record was modified'*/,
614 primary key (user_id)
617 create table user_location_prefs (
618 user_id integer not null /* comment 'user who has the preference' */ references "user" (id),
619 share_location integer default 1 /* comment 'Whether to share location data' */,
620 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
621 modified timestamp /* comment 'date this record was modified' */,
623 primary key (user_id)
628 user_id integer not null /* comment 'user receiving the notice' */ references "user" (id),
629 notice_ids bytea /* comment 'packed list of notice ids' */,
631 primary key (user_id)
635 create sequence conversation_seq;
636 create table conversation (
637 id bigint default nextval('conversation_seq') primary key /* comment 'unique identifier' */,
638 uri varchar(225) unique /* comment 'URI of the conversation' */,
639 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
640 modified timestamp /* comment 'date this record was modified' */
643 create table local_group (
645 group_id integer primary key /* comment 'group represented' */ references user_group (id),
646 nickname varchar(64) unique /* comment 'group represented' */,
648 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
649 modified timestamp /* comment 'date this record was modified' */