bio varchar(140) /* comment 'descriptive biography' */,\r
location varchar(255) /* comment 'physical location' */,\r
created timestamp not null /* comment 'date this record was created' */,\r
- modified timestamp /* comment 'date this record was modified' */\r
+ modified timestamp /* comment 'date this record was modified' */,\r
\r
-/* FULLTEXT(nickname, fullname, location, bio, homepage) */\r
+ textsearch tsvector\r
);\r
create index profile_nickname_idx on profile using btree(nickname);\r
\r
-\r
-\r
create table avatar (\r
profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id) ,\r
original integer default 0 /* comment 'uploaded by user or generated?' */,\r
email varchar(255) unique /* comment 'email address for password recovery etc.' */,\r
incomingemail varchar(255) unique /* comment 'email address for post-by-email' */,\r
emailnotifysub integer default 1 /* comment 'Notify by email of subscriptions' */,\r
+ emailnotifyfav integer default 1 /* comment 'Notify by email of favorites' */,\r
+ emailnotifynudge integer default 1 /* comment 'Notify by email of nudges' */,\r
emailmicroid integer default 1 /* comment 'whether to publish email microid' */,\r
language varchar(50) /* comment 'preferred language' */,\r
timezone varchar(50) /* comment 'timezone' */,\r
smsemail varchar(255) /* comment 'built from sms and carrier' */,\r
uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,\r
autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */,\r
+ urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */,\r
created timestamp not null /* comment 'date this record was created' */,\r
modified timestamp /* comment 'date this record was modified' */\r
\r
code varchar(32) not null primary key /* comment 'good random code' */,\r
user_id integer not null /* comment 'user who requested confirmation' */ references "user" (id),\r
address varchar(255) not null /* comment 'address (email, Jabber, SMS, etc.)' */,\r
- address_extra varchar(255) not null /* comment 'carrier ID, for SMS' */,\r
+ address_extra varchar(255) not null default '' /* comment 'carrier ID, for SMS' */,\r
address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms")' */,\r
claimed timestamp /* comment 'date this was claimed for queueing' */,\r
sent timestamp /* comment 'date this was sent for queueing' */,\r
);\r
create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber);\r
create index foreign_subscription_subscribed_idx on foreign_subscription using btree(subscribed);\r
+\r
+create table invitation (\r
+ code varchar(32) not null primary key /* comment 'random code for an invitation' */,\r
+ user_id int not null /* comment 'who sent the invitation' */ references "user" (id),\r
+ address varchar(255) not null /* comment 'invitation sent to' */,\r
+ address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms") '*/,\r
+ created timestamp not null /* comment 'date this record was created' */\r
+\r
+);\r
+create index invitation_address_idx on invitation using btree(address,address_type);\r
+create index invitation_user_id_idx on invitation using btree(user_id);\r
+\r
+create table message (\r
+\r
+ id serial primary key /* comment 'unique identifier' */,\r
+ uri varchar(255) unique /* comment 'universally unique identifier' */,\r
+ from_profile integer not null /* comment 'who the message is from' */ references profile (id),\r
+ to_profile integer not null /* comment 'who the message is to' */ references profile (id),\r
+ content varchar(140) /* comment 'message content' */,\r
+ rendered text /* comment 'HTML version of the content' */,\r
+ url varchar(255) /* comment 'URL of any attachment (image, video, bookmark, whatever)' */,\r
+ created timestamp not null /* comment 'date this record was created' */,\r
+ modified timestamp /* comment 'date this record was modified' */,\r
+ source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */\r
+ \r
+);\r
+create index message_from_idx on message using btree(from_profile);\r
+create index message_to_idx on message using btree(to_profile);\r
+create index message_created_idx on message using btree(created);\r
+\r
+/* Textsearch stuff */\r
+\r
+create index textsearch_idx on profile using gist(textsearch);\r
+create index noticecontent_idx on notice using gist(to_tsvector('english',content));\r
+create trigger textsearchupdate before insert or update on profile for each row\r
+execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);\r
+\r