1 /* local and remote users have profiles */
4 id integer auto_increment 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 created datetime not null comment 'date this record was created',
12 modified timestamp comment 'date this record was modified',
14 index profile_nickname_idx (nickname),
15 FULLTEXT(nickname, fullname, location, bio, homepage)
19 profile_id integer not null comment 'foreign key to profile table' references profile (id),
20 original boolean default false comment 'uploaded by user or generated?',
21 width integer not null comment 'image width',
22 height integer not null comment 'image height',
23 mediatype varchar(32) not null comment 'file type',
24 filename varchar(255) null comment 'local filename, if local',
25 url varchar(255) unique key comment 'avatar location',
26 created datetime not null comment 'date this record was created',
27 modified timestamp comment 'date this record was modified',
29 constraint primary key (profile_id, width, height),
30 index avatar_profile_id_idx (profile_id)
33 create table sms_carrier (
34 id integer auto_increment primary key comment 'primary key for SMS carrier',
35 name varchar(64) unique key comment 'name of the carrier',
36 email_pattern varchar(255) not null comment 'sprintf pattern for making an email address from a phone number',
37 created datetime not null comment 'date this record was created',
38 modified timestamp comment 'date this record was modified'
44 id integer primary key comment 'foreign key to profile table' references profile (id),
45 nickname varchar(64) unique key comment 'nickname or username, duped in profile',
46 password varchar(255) comment 'salted password, can be null for OpenID users',
47 email varchar(255) unique key comment 'email address for password recovery etc.',
48 incomingemail varchar(255) unique key comment 'email address for post-by-email',
49 emailnotifysub tinyint default 1 comment 'Notify by email of subscriptions',
50 emailpost tinyint default 1 comment 'Post by email',
51 jabber varchar(255) unique key comment 'jabber ID for notices',
52 jabbernotify tinyint default 0 comment 'whether to send notices to jabber',
53 jabberreplies tinyint default 0 comment 'whether to send notices to jabber on replies',
54 updatefrompresence tinyint default 0 comment 'whether to record updates from Jabber presence notices',
55 sms varchar(64) unique key comment 'sms phone number',
56 carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
57 smsnotify tinyint default 0 comment 'whether to send notices to SMS',
58 uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
59 created datetime not null comment 'date this record was created',
60 modified timestamp comment 'date this record was modified'
65 create table remote_profile (
66 id integer primary key comment 'foreign key to profile table' references profile (id),
67 uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
68 postnoticeurl varchar(255) comment 'URL we use for posting notices',
69 updateprofileurl varchar(255) comment 'URL we use for updates to this profile',
70 created datetime not null comment 'date this record was created',
71 modified timestamp comment 'date this record was modified'
74 create table subscription (
75 subscriber integer not null comment 'profile listening',
76 subscribed integer not null comment 'profile being listened to',
77 token varchar(255) comment 'authorization token',
78 secret varchar(255) comment 'token secret',
79 created datetime not null comment 'date this record was created',
80 modified timestamp comment 'date this record was modified',
82 constraint primary key (subscriber, subscribed),
83 index subscription_subscriber_idx (subscriber),
84 index subscription_subscribed_idx (subscribed)
89 id integer auto_increment primary key comment 'unique identifier',
90 profile_id integer not null comment 'who made the update' references profile (id),
91 uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
92 content varchar(140) comment 'update content',
93 rendered text comment 'HTML version of the content',
94 url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
95 created datetime not null comment 'date this record was created',
96 modified timestamp comment 'date this record was modified',
97 reply_to integer comment 'notice replied to (usually a guess)' references notice (id),
99 index notice_profile_id_idx (profile_id),
105 notice_id integer not null comment 'notice that is the reply' references notice (id),
106 profile_id integer not null comment 'profile replied to' references profile (id),
107 modified timestamp not null comment 'date this record was modified',
108 replied_id integer comment 'notice replied to (not used, see notice.reply_to)',
110 constraint primary key (notice_id, profile_id),
111 index reply_notice_id_idx (notice_id),
112 index reply_profile_id_idx (profile_id),
113 index reply_replied_id_idx (replied_id)
117 /* tables for OAuth */
119 create table consumer (
120 consumer_key varchar(255) primary key comment 'unique identifier, root URL',
121 seed char(32) not null comment 'seed for new tokens by this consumer',
123 created datetime not null comment 'date this record was created',
124 modified timestamp comment 'date this record was modified'
128 consumer_key varchar(255) not null comment 'unique identifier, root URL' references consumer (consumer_key),
129 tok char(32) not null comment 'identifying value',
130 secret char(32) not null comment 'secret value',
131 type tinyint not null default 0 comment 'request or access',
132 state tinyint default 0 comment 'for requests; 0 = initial, 1 = authorized, 2 = used',
134 created datetime not null comment 'date this record was created',
135 modified timestamp comment 'date this record was modified',
137 constraint primary key (consumer_key, tok)
141 consumer_key varchar(255) not null comment 'unique identifier, root URL',
142 tok char(32) not null comment 'identifying value',
143 nonce char(32) not null comment 'nonce',
144 ts datetime not null comment 'timestamp sent',
146 created datetime not null comment 'date this record was created',
147 modified timestamp comment 'date this record was modified',
149 constraint primary key (consumer_key, tok, nonce),
150 constraint foreign key (consumer_key, tok) references token (consumer_key, tok)
153 /* One-to-many relationship of user to openid_url */
155 create table user_openid (
156 canonical varchar(255) primary key comment 'Canonical true URL',
157 display varchar(255) not null unique key comment 'URL for viewing, may be different from canonical',
158 user_id integer not null comment 'user owning this URL' references user (id),
159 created datetime not null comment 'date this record was created',
160 modified timestamp comment 'date this record was modified',
162 index user_openid_user_id_idx (user_id)
165 /* These are used by JanRain OpenID library */
167 create table oid_associations (
173 assoc_type VARCHAR(64),
174 PRIMARY KEY (server_url(255), handle)
177 create table oid_nonces (
178 server_url VARCHAR(2047),
181 UNIQUE (server_url(255), timestamp, salt)
184 create table confirm_address (
185 code varchar(32) not null primary key comment 'good random code',
186 user_id integer not null comment 'user who requested confirmation' references user (id),
187 address varchar(255) not null comment 'address (email, Jabber, SMS, etc.)',
188 address_extra varchar(255) not null comment 'carrier ID, for SMS',
189 address_type varchar(8) not null comment 'address type ("email", "jabber", "sms")',
190 claimed datetime comment 'date this was claimed for queueing',
191 sent datetime comment 'date this was sent for queueing',
192 modified timestamp comment 'date this record was modified'
195 create table remember_me (
196 code varchar(32) not null primary key comment 'good random code',
197 user_id integer not null comment 'user who is logged in' references user (id),
198 modified timestamp comment 'date this record was modified'
201 create table queue_item (
203 notice_id integer not null primary key comment 'notice queued' references notice (id),
204 transport varchar(8) not null comment 'queue for what? "email", "jabber", "sms", "irc", ...',
205 created datetime not null comment 'date this record was created',
206 claimed datetime comment 'date this item was claimed',
208 index queue_item_created_idx (created)