2 /* local and remote users have profiles */
\r
4 create sequence profile_seq;
\r
5 create table profile (
\r
6 id bigint default nextval('profile_seq') primary key /* comment 'unique identifier' */,
\r
7 nickname varchar(64) not null /* comment 'nickname or username' */,
\r
8 fullname varchar(255) /* comment 'display name' */,
\r
9 profileurl varchar(255) /* comment 'URL, cached so we dont regenerate' */,
\r
10 homepage varchar(255) /* comment 'identifying URL' */,
\r
11 bio varchar(140) /* comment 'descriptive biography' */,
\r
12 location varchar(255) /* comment 'physical location' */,
\r
13 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
14 modified timestamp /* comment 'date this record was modified' */,
\r
18 create index profile_nickname_idx on profile using btree(nickname);
\r
20 create table avatar (
\r
21 profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id) ,
\r
22 original integer default 0 /* comment 'uploaded by user or generated?' */,
\r
23 width integer not null /* comment 'image width' */,
\r
24 height integer not null /* comment 'image height' */,
\r
25 mediatype varchar(32) not null /* comment 'file type' */,
\r
26 filename varchar(255) null /* comment 'local filename, if local' */,
\r
27 url varchar(255) unique /* comment 'avatar location' */,
\r
28 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
29 modified timestamp /* comment 'date this record was modified' */,
\r
31 primary key(profile_id, width, height)
\r
33 create index avatar_profile_id_idx on avatar using btree(profile_id);
\r
35 create sequence sms_carrier_seq;
\r
36 create table sms_carrier (
\r
37 id bigint default nextval('sms_carrier_seq') primary key /* comment 'primary key for SMS carrier' */,
\r
38 name varchar(64) unique /* comment 'name of the carrier' */,
\r
39 email_pattern varchar(255) not null /* comment 'sprintf pattern for making an email address from a phone number' */,
\r
40 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
41 modified timestamp /* comment 'date this record was modified ' */
\r
46 create table "user" (
\r
47 id integer primary key /* comment 'foreign key to profile table' */ references profile (id) ,
\r
48 nickname varchar(64) unique /* comment 'nickname or username, duped in profile' */,
\r
49 password varchar(255) /* comment 'salted password, can be null for OpenID users' */,
\r
50 email varchar(255) unique /* comment 'email address for password recovery etc.' */,
\r
51 incomingemail varchar(255) unique /* comment 'email address for post-by-email' */,
\r
52 emailnotifysub integer default 1 /* comment 'Notify by email of subscriptions' */,
\r
53 emailnotifyfav integer default 1 /* comment 'Notify by email of favorites' */,
\r
54 emailnotifynudge integer default 1 /* comment 'Notify by email of nudges' */,
\r
55 emailnotifymsg integer default 1 /* comment 'Notify by email of direct messages' */,
\r
56 emailnotifyattn integer default 1 /* command 'Notify by email of @-replies' */,
\r
57 emailmicroid integer default 1 /* comment 'whether to publish email microid' */,
\r
58 language varchar(50) /* comment 'preferred language' */,
\r
59 timezone varchar(50) /* comment 'timezone' */,
\r
60 emailpost integer default 1 /* comment 'Post by email' */,
\r
61 jabber varchar(255) unique /* comment 'jabber ID for notices' */,
\r
62 jabbernotify integer default 0 /* comment 'whether to send notices to jabber' */,
\r
63 jabberreplies integer default 0 /* comment 'whether to send notices to jabber on replies' */,
\r
64 jabbermicroid integer default 1 /* comment 'whether to publish xmpp microid' */,
\r
65 updatefrompresence integer default 0 /* comment 'whether to record updates from Jabber presence notices' */,
\r
66 sms varchar(64) unique /* comment 'sms phone number' */,
\r
67 carrier integer /* comment 'foreign key to sms_carrier' */ references sms_carrier (id) ,
\r
68 smsnotify integer default 0 /* comment 'whether to send notices to SMS' */,
\r
69 smsreplies integer default 0 /* comment 'whether to send notices to SMS on replies' */,
\r
70 smsemail varchar(255) /* comment 'built from sms and carrier' */,
\r
71 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
\r
72 autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */,
\r
73 urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */,
\r
74 inboxed integer default 0 /* comment 'has an inbox been created for this user?' */,
\r
75 design_id integer /* comment 'id of a design' */references design(id),
\r
76 viewdesigns integer default 1 /* comment 'whether to view user-provided designs'*/,
\r
77 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
78 modified timestamp /* comment 'date this record was modified' */
\r
81 create index user_smsemail_idx on "user" using btree(smsemail);
\r
85 create table remote_profile (
\r
86 id integer primary key /* comment 'foreign key to profile table' */ references profile (id) ,
\r
87 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
\r
88 postnoticeurl varchar(255) /* comment 'URL we use for posting notices' */,
\r
89 updateprofileurl varchar(255) /* comment 'URL we use for updates to this profile' */,
\r
90 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
91 modified timestamp /* comment 'date this record was modified' */
\r
94 create table subscription (
\r
95 subscriber integer not null /* comment 'profile listening' */,
\r
96 subscribed integer not null /* comment 'profile being listened to' */,
\r
97 jabber integer default 1 /* comment 'deliver jabber messages' */,
\r
98 sms integer default 1 /* comment 'deliver sms messages' */,
\r
99 token varchar(255) /* comment 'authorization token' */,
\r
100 secret varchar(255) /* comment 'token secret' */,
\r
101 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
102 modified timestamp /* comment 'date this record was modified' */,
\r
104 primary key (subscriber, subscribed)
\r
106 create index subscription_subscriber_idx on subscription using btree(subscriber);
\r
107 create index subscription_subscribed_idx on subscription using btree(subscribed);
\r
109 create sequence notice_seq;
\r
110 create table notice (
\r
112 id bigint default nextval('notice_seq') primary key /* comment 'unique identifier' */,
\r
113 profile_id integer not null /* comment 'who made the update' */ references profile (id) ,
\r
114 uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,
\r
115 content varchar(140) /* comment 'update content' */,
\r
116 rendered text /* comment 'HTML version of the content' */,
\r
117 url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,
\r
118 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
119 modified timestamp /* comment 'date this record was modified' */,
\r
120 reply_to integer /* comment 'notice replied to (usually a guess)' */ references notice (id) ,
\r
121 is_local integer default 0 /* comment 'notice was generated by a user' */,
\r
122 source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */,
\r
123 conversation integer /*id of root notice in this conversation' */ references notice (id)
\r
126 /* FULLTEXT(content) */
\r
128 create index notice_profile_id_idx on notice using btree(profile_id);
\r
129 create index notice_created_idx on notice using btree(created);
\r
131 create table notice_source (
\r
132 code varchar(32) primary key not null /* comment 'source code' */,
\r
133 name varchar(255) not null /* comment 'name of the source' */,
\r
134 url varchar(255) not null /* comment 'url to link to' */,
\r
135 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
136 modified timestamp /* comment 'date this record was modified' */
\r
139 create table reply (
\r
141 notice_id integer not null /* comment 'notice that is the reply' */ references notice (id) ,
\r
142 profile_id integer not null /* comment 'profile replied to' */ references profile (id) ,
\r
143 modified timestamp /* comment 'date this record was modified' */,
\r
144 replied_id integer /* comment 'notice replied to (not used, see notice.reply_to)' */,
\r
146 primary key (notice_id, profile_id)
\r
149 create index reply_notice_id_idx on reply using btree(notice_id);
\r
150 create index reply_profile_id_idx on reply using btree(profile_id);
\r
151 create index reply_replied_id_idx on reply using btree(replied_id);
\r
153 create table fave (
\r
155 notice_id integer not null /* comment 'notice that is the favorite' */ references notice (id),
\r
156 user_id integer not null /* comment 'user who likes this notice' */ references "user" (id) ,
\r
157 modified timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was modified' */,
\r
158 primary key (notice_id, user_id)
\r
161 create index fave_notice_id_idx on fave using btree(notice_id);
\r
162 create index fave_user_id_idx on fave using btree(user_id);
\r
163 create index fave_modified_idx on fave using btree(modified);
\r
165 /* tables for OAuth */
\r
167 create table consumer (
\r
168 consumer_key varchar(255) primary key /* comment 'unique identifier, root URL' */,
\r
169 seed char(32) not null /* comment 'seed for new tokens by this consumer' */,
\r
171 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
172 modified timestamp /* comment 'date this record was modified' */
\r
175 create table token (
\r
176 consumer_key varchar(255) not null /* comment 'unique identifier, root URL' */ references consumer (consumer_key),
\r
177 tok char(32) not null /* comment 'identifying value' */,
\r
178 secret char(32) not null /* comment 'secret value' */,
\r
179 type integer not null default 0 /* comment 'request or access' */,
\r
180 state integer default 0 /* comment 'for requests 0 = initial, 1 = authorized, 2 = used' */,
\r
182 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
183 modified timestamp /* comment 'date this record was modified' */,
\r
185 primary key (consumer_key, tok)
\r
188 create table nonce (
\r
189 consumer_key varchar(255) not null /* comment 'unique identifier, root URL' */,
\r
190 tok char(32) /* comment 'buggy old value, ignored' */,
\r
191 nonce char(32) null /* comment 'buggy old value, ignored */,
\r
192 ts integer not null /* comment 'timestamp sent' values are epoch, and only used internally */,
\r
194 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
195 modified timestamp /* comment 'date this record was modified' */,
\r
197 primary key (consumer_key, ts, nonce)
\r
200 /* One-to-many relationship of user to openid_url */
\r
202 create table user_openid (
\r
203 canonical varchar(255) primary key /* comment 'Canonical true URL' */,
\r
204 display varchar(255) not null unique /* comment 'URL for viewing, may be different from canonical' */,
\r
205 user_id integer not null /* comment 'user owning this URL' */ references "user" (id) ,
\r
206 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
207 modified timestamp /* comment 'date this record was modified' */
\r
210 create index user_openid_user_id_idx on user_openid using btree(user_id);
\r
212 /* These are used by JanRain OpenID library */
\r
214 create table oid_associations (
\r
215 server_url varchar(2047),
\r
216 handle varchar(255),
\r
220 assoc_type varchar(64),
\r
221 primary key (server_url, handle)
\r
224 create table oid_nonces (
\r
225 server_url varchar(2047),
\r
226 "timestamp" integer,
\r
227 salt character(40),
\r
228 unique (server_url, "timestamp", salt)
\r
231 create table confirm_address (
\r
232 code varchar(32) not null primary key /* comment 'good random code' */,
\r
233 user_id integer not null /* comment 'user who requested confirmation' */ references "user" (id),
\r
234 address varchar(255) not null /* comment 'address (email, Jabber, SMS, etc.)' */,
\r
235 address_extra varchar(255) not null default '' /* comment 'carrier ID, for SMS' */,
\r
236 address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms")' */,
\r
237 claimed timestamp /* comment 'date this was claimed for queueing' */,
\r
238 sent timestamp /* comment 'date this was sent for queueing' */,
\r
239 modified timestamp /* comment 'date this record was modified' */
\r
242 create table remember_me (
\r
243 code varchar(32) not null primary key /* comment 'good random code' */,
\r
244 user_id integer not null /* comment 'user who is logged in' */ references "user" (id),
\r
245 modified timestamp /* comment 'date this record was modified' */
\r
248 create table queue_item (
\r
250 notice_id integer not null /* comment 'notice queued' */ references notice (id) ,
\r
251 transport varchar(8) not null /* comment 'queue for what? "email", "jabber", "sms", "irc", ...' */,
\r
252 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
253 claimed timestamp /* comment 'date this item was claimed' */,
\r
255 primary key (notice_id, transport)
\r
258 create index queue_item_created_idx on queue_item using btree(created);
\r
261 create table notice_tag (
\r
262 tag varchar( 64 ) not null /* comment 'hash tag associated with this notice' */,
\r
263 notice_id integer not null /* comment 'notice tagged' */ references notice (id) ,
\r
264 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
266 primary key (tag, notice_id)
\r
268 create index notice_tag_created_idx on notice_tag using btree(created);
\r
270 /* Synching with foreign services */
\r
272 create table foreign_service (
\r
273 id int not null primary key /* comment 'numeric key for service' */,
\r
274 name varchar(32) not null unique /* comment 'name of the service' */,
\r
275 description varchar(255) /* comment 'description' */,
\r
276 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
277 modified timestamp /* comment 'date this record was modified' */
\r
280 create table foreign_user (
\r
281 id int not null unique /* comment 'unique numeric key on foreign service' */,
\r
282 service int not null /* comment 'foreign key to service' */ references foreign_service(id) ,
\r
283 uri varchar(255) not null unique /* comment 'identifying URI' */,
\r
284 nickname varchar(255) /* comment 'nickname on foreign service' */,
\r
285 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
286 modified timestamp /* comment 'date this record was modified' */,
\r
288 primary key (id, service)
\r
291 create table foreign_link (
\r
292 user_id int /* comment 'link to user on this system, if exists' */ references "user" (id),
\r
293 foreign_id int /* comment 'link' */ references foreign_user (id),
\r
294 service int not null /* comment 'foreign key to service' */ references foreign_service (id),
\r
295 credentials varchar(255) /* comment 'authc credentials, typically a password' */,
\r
296 noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */,
\r
297 friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */,
\r
298 profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */,
\r
299 last_noticesync timestamp default null /* comment 'last time notices were imported' */,
\r
300 last_friendsync timestamp default null /* comment 'last time friends were imported' */,
\r
301 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
302 modified timestamp /* comment 'date this record was modified' */,
\r
304 primary key (user_id,foreign_id,service)
\r
306 create index foreign_user_user_id_idx on foreign_link using btree(user_id);
\r
308 create table foreign_subscription (
\r
309 service int not null /* comment 'service where relationship happens' */ references foreign_service(id) ,
\r
310 subscriber int not null /* comment 'subscriber on foreign service' */ ,
\r
311 subscribed int not null /* comment 'subscribed user' */ ,
\r
312 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
314 primary key (service, subscriber, subscribed)
\r
316 create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber);
\r
317 create index foreign_subscription_subscribed_idx on foreign_subscription using btree(subscribed);
\r
319 create table invitation (
\r
320 code varchar(32) not null primary key /* comment 'random code for an invitation' */,
\r
321 user_id int not null /* comment 'who sent the invitation' */ references "user" (id),
\r
322 address varchar(255) not null /* comment 'invitation sent to' */,
\r
323 address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms") '*/,
\r
324 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */
\r
327 create index invitation_address_idx on invitation using btree(address,address_type);
\r
328 create index invitation_user_id_idx on invitation using btree(user_id);
\r
330 create sequence message_seq;
\r
331 create table message (
\r
333 id bigint default nextval('message_seq') primary key /* comment 'unique identifier' */,
\r
334 uri varchar(255) unique /* comment 'universally unique identifier' */,
\r
335 from_profile integer not null /* comment 'who the message is from' */ references profile (id),
\r
336 to_profile integer not null /* comment 'who the message is to' */ references profile (id),
\r
337 content varchar(140) /* comment 'message content' */,
\r
338 rendered text /* comment 'HTML version of the content' */,
\r
339 url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,
\r
340 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
341 modified timestamp /* comment 'date this record was modified' */,
\r
342 source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */
\r
345 create index message_from_idx on message using btree(from_profile);
\r
346 create index message_to_idx on message using btree(to_profile);
\r
347 create index message_created_idx on message using btree(created);
\r
349 create table notice_inbox (
\r
351 user_id integer not null /* comment 'user receiving the message' */ references "user" (id),
\r
352 notice_id integer not null /* comment 'notice received' */ references notice (id),
\r
353 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
\r
354 source integer default 1 /* comment 'reason it is in the inbox: 1=subscription' */,
\r
356 primary key (user_id, notice_id)
\r
358 create index notice_inbox_notice_id_idx on notice_inbox using btree(notice_id);
\r
360 create table profile_tag (
\r
361 tagger integer not null /* comment 'user making the tag' */ references "user" (id),
\r
362 tagged integer not null /* comment 'profile tagged' */ references profile (id),
\r
363 tag varchar(64) not null /* comment 'hash tag associated with this notice' */,
\r
364 modified timestamp /* comment 'date the tag was added' */,
\r
366 primary key (tagger, tagged, tag)
\r
368 create index profile_tag_modified_idx on profile_tag using btree(modified);
\r
369 create index profile_tag_tagger_tag_idx on profile_tag using btree(tagger,tag);
\r
371 create table profile_block (
\r
373 blocker integer not null /* comment 'user making the block' */ references "user" (id),
\r
374 blocked integer not null /* comment 'profile that is blocked' */ references profile (id),
\r
375 modified timestamp /* comment 'date of blocking' */,
\r
377 primary key (blocker, blocked)
\r
381 create sequence design_seq;
\r
382 create table design (
\r
383 id bigint default nextval('design_seq') /* comment 'design ID'*/,
\r
384 backgroundcolor integer /* comment 'main background color'*/ ,
\r
385 contentcolor integer /*comment 'content area background color'*/ ,
\r
386 sidebarcolor integer /*comment 'sidebar background color'*/ ,
\r
387 textcolor integer /*comment 'text color'*/ ,
\r
388 linkcolor integer /*comment 'link color'*/,
\r
389 backgroundimage varchar(255) /*comment 'background image, if any'*/,
\r
390 disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/,
\r
395 create sequence user_group_seq;
\r
396 create table user_group (
\r
398 id bigint default nextval('user_group_seq') primary key /* comment 'unique identifier' */,
\r
400 nickname varchar(64) unique /* comment 'nickname for addressing' */,
\r
401 fullname varchar(255) /* comment 'display name' */,
\r
402 homepage varchar(255) /* comment 'URL, cached so we dont regenerate' */,
\r
403 description varchar(140) /* comment 'descriptive biography' */,
\r
404 location varchar(255) /* comment 'related physical location, if any' */,
\r
406 original_logo varchar(255) /* comment 'original size logo' */,
\r
407 homepage_logo varchar(255) /* comment 'homepage (profile) size logo' */,
\r
408 stream_logo varchar(255) /* comment 'stream-sized logo' */,
\r
409 mini_logo varchar(255) /* comment 'mini logo' */,
\r
410 design_id integer /*comment 'id of a design' */ references design(id),
\r
413 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
414 modified timestamp /* comment 'date this record was modified' */
\r
417 create index user_group_nickname_idx on user_group using btree(nickname);
\r
419 create table group_member (
\r
421 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
\r
422 profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id),
\r
423 is_admin integer default 0 /* comment 'is this user an admin?' */,
\r
425 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
426 modified timestamp /* comment 'date this record was modified' */,
\r
428 primary key (group_id, profile_id)
\r
431 create table related_group (
\r
433 group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id) ,
\r
434 related_group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id),
\r
436 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
\r
438 primary key (group_id, related_group_id)
\r
442 create table group_inbox (
\r
443 group_id integer not null /* comment 'group receiving the message' references user_group (id) */,
\r
444 notice_id integer not null /* comment 'notice received' references notice (id) */,
\r
445 created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
\r
446 primary key (group_id, notice_id)
\r
448 create index group_inbox_created_idx on group_inbox using btree(created);
\r
451 /*attachments and URLs stuff */
\r
452 create sequence file_seq;
\r
453 create table file (
\r
454 id bigint default nextval('file_seq') primary key /* comment 'unique identifier' */,
\r
455 url varchar(255) unique,
\r
456 mimetype varchar(50),
\r
458 title varchar(255),
\r
461 filename text /* comment 'if a local file, name of the file' */,
\r
462 modified timestamp default CURRENT_TIMESTAMP /* comment 'date this record was modified'*/
\r
465 create sequence file_oembed_seq;
\r
466 create table file_oembed (
\r
467 id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
\r
468 file_id bigint unique,
\r
469 version varchar(20),
\r
471 provider varchar(50),
\r
472 provider_url varchar(255),
\r
476 title varchar(255),
\r
477 author_name varchar(50),
\r
478 author_url varchar(255),
\r
482 create sequence file_redirection_seq;
\r
483 create table file_redirection (
\r
484 id bigint default nextval('file_redirection_seq') primary key /* comment 'unique identifier' */,
\r
485 url varchar(255) unique,
\r
487 redirections integer,
\r
491 create sequence file_thumbnail_seq;
\r
492 create table file_thumbnail (
\r
493 id bigint default nextval('file_thumbnail_seq') primary key /* comment 'unique identifier' */,
\r
494 file_id bigint unique,
\r
495 url varchar(255) unique,
\r
500 create sequence file_to_post_seq;
\r
501 create table file_to_post (
\r
502 id bigint default nextval('file_to_post_seq') primary key /* comment 'unique identifier' */,
\r
506 unique(file_id, post_id)
\r
509 create table group_block (
\r
510 group_id integer not null /* comment 'group profile is blocked from' */ references user_group (id),
\r
511 blocked integer not null /* comment 'profile that is blocked' */references profile (id),
\r
512 blocker integer not null /* comment 'user making the block'*/ references "user" (id),
\r
513 modified timestamp /* comment 'date of blocking'*/ ,
\r
515 primary key (group_id, blocked)
\r
518 create table group_alias (
\r
520 alias varchar(64) /* comment 'additional nickname for the group'*/ ,
\r
521 group_id integer not null /* comment 'group profile is blocked from'*/ references user_group (id),
\r
522 modified timestamp /* comment 'date alias was created'*/,
\r
523 primary key (alias)
\r
526 create index group_alias_group_id_idx on group_alias (group_id);
\r
529 /* Textsearch stuff */
\r
531 create index textsearch_idx on profile using gist(textsearch);
\r
532 create index noticecontent_idx on notice using gist(to_tsvector('english',content));
\r
533 create trigger textsearchupdate before insert or update on profile for each row
\r
534 execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);
\r