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 default CURRENT_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 (
290 id serial /* comment 'unique identifier'*/,
291 frame bytea not null /* comment 'data: object reference or opaque string'*/,
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'*/,
297 create index queue_item_created_idx on queue_item using btree(created);
300 create table notice_tag (
301 tag varchar( 64 ) not null /* comment 'hash tag associated with this notice' */,
302 notice_id integer not null /* comment 'notice tagged' */ references notice (id) ,
303 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
305 primary key (tag, notice_id)
307 create index notice_tag_created_idx on notice_tag using btree(created);
309 /* Synching with foreign services */
311 create table foreign_service (
312 id int not null primary key /* comment 'numeric key for service' */,
313 name varchar(32) not null unique /* comment 'name of the service' */,
314 description varchar(255) /* comment 'description' */,
315 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
316 modified timestamp /* comment 'date this record was modified' */
319 create table foreign_user (
320 id int not null unique /* comment 'unique numeric key on foreign service' */,
321 service int not null /* comment 'foreign key to service' */ references foreign_service(id) ,
322 uri varchar(255) not null unique /* comment 'identifying URI' */,
323 nickname varchar(255) /* comment 'nickname on foreign service' */,
324 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
325 modified timestamp /* comment 'date this record was modified' */,
327 primary key (id, service)
330 create table foreign_link (
331 user_id int /* comment 'link to user on this system, if exists' */ references "user" (id),
332 foreign_id int /* comment 'link' */ references foreign_user (id),
333 service int not null /* comment 'foreign key to service' */ references foreign_service (id),
334 credentials varchar(255) /* comment 'authc credentials, typically a password' */,
335 noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */,
336 friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */,
337 profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */,
338 last_noticesync timestamp default null /* comment 'last time notices were imported' */,
339 last_friendsync timestamp default null /* comment 'last time friends were imported' */,
340 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
341 modified timestamp /* comment 'date this record was modified' */,
343 primary key (user_id,foreign_id,service)
345 create index foreign_user_user_id_idx on foreign_link using btree(user_id);
347 create table foreign_subscription (
348 service int not null /* comment 'service where relationship happens' */ references foreign_service(id) ,
349 subscriber int not null /* comment 'subscriber on foreign service' */ ,
350 subscribed int not null /* comment 'subscribed user' */ ,
351 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
353 primary key (service, subscriber, subscribed)
355 create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber);
356 create index foreign_subscription_subscribed_idx on foreign_subscription using btree(subscribed);
358 create table invitation (
359 code varchar(32) not null primary key /* comment 'random code for an invitation' */,
360 user_id int not null /* comment 'who sent the invitation' */ references "user" (id),
361 address varchar(255) not null /* comment 'invitation sent to' */,
362 address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms") '*/,
363 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */
366 create index invitation_address_idx on invitation using btree(address,address_type);
367 create index invitation_user_id_idx on invitation using btree(user_id);
369 create sequence message_seq;
370 create table message (
372 id bigint default nextval('message_seq') primary key /* comment 'unique identifier' */,
373 uri varchar(255) unique /* comment 'universally unique identifier' */,
374 from_profile integer not null /* comment 'who the message is from' */ references profile (id),
375 to_profile integer not null /* comment 'who the message is to' */ references profile (id),
376 content varchar(140) /* comment 'message content' */,
377 rendered text /* comment 'HTML version of the content' */,
378 url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,
379 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
380 modified timestamp /* comment 'date this record was modified' */,
381 source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */
384 create index message_from_idx on message using btree(from_profile);
385 create index message_to_idx on message using btree(to_profile);
386 create index message_created_idx on message using btree(created);
388 create table notice_inbox (
390 user_id integer not null /* comment 'user receiving the message' */ references "user" (id),
391 notice_id integer not null /* comment 'notice received' */ references notice (id),
392 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
393 source integer default 1 /* comment 'reason it is in the inbox: 1=subscription' */,
395 primary key (user_id, notice_id)
397 create index notice_inbox_notice_id_idx on notice_inbox using btree(notice_id);
399 create table profile_tag (
400 tagger integer not null /* comment 'user making the tag' */ references "user" (id),
401 tagged integer not null /* comment 'profile tagged' */ references profile (id),
402 tag varchar(64) not null /* comment 'hash tag associated with this notice' */,
403 modified timestamp /* comment 'date the tag was added' */,
405 primary key (tagger, tagged, tag)
407 create index profile_tag_modified_idx on profile_tag using btree(modified);
408 create index profile_tag_tagger_tag_idx on profile_tag using btree(tagger,tag);
410 create table profile_block (
412 blocker integer not null /* comment 'user making the block' */ references "user" (id),
413 blocked integer not null /* comment 'profile that is blocked' */ references profile (id),
414 modified timestamp /* comment 'date of blocking' */,
416 primary key (blocker, blocked)
420 create sequence user_group_seq;
421 create table user_group (
423 id bigint default nextval('user_group_seq') primary key /* comment 'unique identifier' */,
425 nickname varchar(64) unique /* comment 'nickname for addressing' */,
426 fullname varchar(255) /* comment 'display name' */,
427 homepage varchar(255) /* comment 'URL, cached so we dont regenerate' */,
428 description varchar(140) /* comment 'descriptive biography' */,
429 location varchar(255) /* comment 'related physical location, if any' */,
431 original_logo varchar(255) /* comment 'original size logo' */,
432 homepage_logo varchar(255) /* comment 'homepage (profile) size logo' */,
433 stream_logo varchar(255) /* comment 'stream-sized logo' */,
434 mini_logo varchar(255) /* comment 'mini logo' */,
435 design_id integer /*comment 'id of a design' */ references design(id),
437 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
438 modified timestamp /* comment 'date this record was modified' */
441 create index user_group_nickname_idx on user_group using btree(nickname);
443 create table group_member (
445 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
446 profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id),
447 is_admin integer default 0 /* comment 'is this user an admin?' */,
449 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
450 modified timestamp /* comment 'date this record was modified' */,
452 primary key (group_id, profile_id)
455 create table related_group (
457 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id) ,
458 related_group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
460 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
462 primary key (group_id, related_group_id)
466 create table group_inbox (
467 group_id integer not null /* comment 'group receiving the message' references user_group (id) */,
468 notice_id integer not null /* comment 'notice received' references notice (id) */,
469 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
470 primary key (group_id, notice_id)
472 create index group_inbox_created_idx on group_inbox using btree(created);
474 /*attachments and URLs stuff */
475 create sequence file_seq;
477 id bigint default nextval('file_seq') primary key /* comment 'unique identifier' */,
478 url varchar(255) unique,
479 mimetype varchar(50),
484 filename text /* comment 'if a local file, name of the file' */,
485 modified timestamp default CURRENT_TIMESTAMP /* comment 'date this record was modified'*/
488 create sequence file_oembed_seq;
489 create table file_oembed (
490 file_id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
493 mimetype varchar(50),
494 provider varchar(50),
495 provider_url varchar(255),
500 author_name varchar(50),
501 author_url varchar(255),
505 create sequence file_redirection_seq;
506 create table file_redirection (
507 url varchar(255) primary key,
509 redirections integer,
513 create sequence file_thumbnail_seq;
514 create table file_thumbnail (
515 file_id bigint primary key,
516 url varchar(255) unique,
521 create sequence file_to_post_seq;
522 create table file_to_post (
526 primary key (file_id, post_id)
529 create table group_block (
530 group_id integer not null /* comment 'group profile is blocked from' */ references user_group (id),
531 blocked integer not null /* comment 'profile that is blocked' */references profile (id),
532 blocker integer not null /* comment 'user making the block'*/ references "user" (id),
533 modified timestamp /* comment 'date of blocking'*/ ,
535 primary key (group_id, blocked)
538 create table group_alias (
540 alias varchar(64) /* comment 'additional nickname for the group'*/ ,
541 group_id integer not null /* comment 'group profile is blocked from'*/ references user_group (id),
542 modified timestamp /* comment 'date alias was created'*/,
546 create index group_alias_group_id_idx on group_alias (group_id);
548 create table session (
550 id varchar(32) primary key /* comment 'session ID'*/,
551 session_data text /* comment 'session data'*/,
552 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
553 modified integer DEFAULT extract(epoch from CURRENT_TIMESTAMP) /* comment 'date this record was modified'*/
556 create index session_modified_idx on session (modified);
558 create table deleted_notice (
560 id integer primary key /* comment 'identity of notice'*/ ,
561 profile_id integer /* not null comment 'author of the notice'*/,
562 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI'*/,
563 created timestamp not null /* comment 'date the notice record was created'*/ ,
564 deleted timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date the notice record was created'*/
567 CREATE index deleted_notice_profile_id_idx on deleted_notice (profile_id);
569 /* Textsearch stuff */
571 create index textsearch_idx on profile using gist(textsearch);
572 create index noticecontent_idx on notice using gist(to_tsvector('english',content));
573 create trigger textsearchupdate before insert or update on profile for each row
574 execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);
576 create table config (
578 section varchar(32) /* comment 'configuration section'*/,
579 setting varchar(32) /* comment 'configuration setting'*/,
580 value varchar(255) /* comment 'configuration value'*/,
582 primary key (section, setting)
586 create table profile_role (
588 profile_id integer not null /* comment 'account having the role'*/ references profile (id),
589 role varchar(32) not null /* comment 'string representing the role'*/,
590 created timestamp /* not null comment 'date the role was granted'*/,
592 primary key (profile_id, role)
596 create table location_namespace (
598 id integer /*comment 'identity for this namespace'*/,
599 description text /* comment 'description of the namespace'*/ ,
600 created integer not null /*comment 'date the record was created*/ ,
601 /* modified timestamp comment 'date this record was modified',*/
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 timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
610 modified timestamp /* comment 'date this record was modified'*/,
612 primary key (user_id)
615 create table user_location_prefs (
616 user_id integer not null /* comment 'user who has the preference' */ references "user" (id),
617 share_location integer default 1 /* comment 'Whether to share location data' */,
618 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
619 modified timestamp /* comment 'date this record was modified' */,
621 primary key (user_id)
626 user_id integer not null /* comment 'user receiving the notice' */ references "user" (id),
627 notice_ids bytea /* comment 'packed list of notice ids' */,
629 primary key (user_id)
633 create sequence conversation_seq;
634 create table conversation (
635 id bigint default nextval('conversation_seq') primary key /* comment 'unique identifier' */,
636 uri varchar(225) unique /* comment 'URI of the conversation' */,
637 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
638 modified timestamp /* comment 'date this record was modified' */
641 create table local_group (
643 group_id integer primary key /* comment 'group represented' */ references user_group (id),
644 nickname varchar(64) unique /* comment 'group represented' */,
646 created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created' */,
647 modified timestamp /* comment 'date this record was modified' */