]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - db/laconica.sql
3e8361bc67279a8e42a34e5eaecd1145a5f70fd7
[quix0rs-gnu-social.git] / db / laconica.sql
1 /* local and remote users have profiles */
2
3 create table profile (
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',
13
14     index profile_nickname_idx (nickname),
15     FULLTEXT(nickname, fullname, location, bio, homepage)
16 ) ENGINE=MyISAM;
17
18 create table avatar (
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',
28
29     constraint primary key (profile_id, width, height),
30     index avatar_profile_id_idx (profile_id)
31 ) ENGINE=MyISAM;
32
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'
39 ) ENGINE=MyISAM;
40
41 /* local users */
42
43 create table user (
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     jabber varchar(255) unique key comment 'jabber ID for notices',
51     jabbernotify tinyint default 0 comment 'whether to send notices to jabber',
52     jabberreplies tinyint default 0 comment 'whether to send notices to jabber on replies',
53     updatefrompresence tinyint default 0 comment 'whether to record updates from Jabber presence notices',
54     sms varchar(64) unique key comment 'sms phone number',
55     carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
56     smsnotify tinyint default 0 comment 'whether to send notices to SMS',
57     smsreplies tinyint default 0 comment 'whether to send notices to SMS on replies',
58     smsemail varchar(255) comment 'built from sms and carrier',
59     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
60     autosubscribe tinyint default 0 comment 'automatically subscribe to users who subscribe to us',
61     created datetime not null comment 'date this record was created',
62     modified timestamp comment 'date this record was modified',
63     
64     index user_smsemail_idx (smsemail)
65 ) ENGINE=MyISAM;
66
67 /* remote people */
68
69 create table remote_profile (
70     id integer primary key comment 'foreign key to profile table' references profile (id),
71     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
72     postnoticeurl varchar(255) comment 'URL we use for posting notices',
73     updateprofileurl varchar(255) comment 'URL we use for updates to this profile',
74     created datetime not null comment 'date this record was created',
75     modified timestamp comment 'date this record was modified'
76 ) ENGINE=MyISAM;
77
78 create table subscription (
79     subscriber integer not null comment 'profile listening',
80     subscribed integer not null comment 'profile being listened to',
81     token varchar(255) comment 'authorization token',
82     secret varchar(255) comment 'token secret',
83     created datetime not null comment 'date this record was created',
84     modified timestamp comment 'date this record was modified',
85
86     constraint primary key (subscriber, subscribed),
87     index subscription_subscriber_idx (subscriber),
88     index subscription_subscribed_idx (subscribed)
89 ) ENGINE=MyISAM;
90
91 create table notice (
92
93     id integer auto_increment primary key comment 'unique identifier',
94     profile_id integer not null comment 'who made the update' references profile (id),
95     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
96     content varchar(140) comment 'update content',
97     rendered text comment 'HTML version of the content',
98     url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
99     created datetime not null comment 'date this record was created',
100     modified timestamp comment 'date this record was modified',
101     reply_to integer comment 'notice replied to (usually a guess)' references notice (id),
102     is_local tinyint default 0 comment 'notice was generated by a user',
103     source varchar(8) comment 'source of comment, like "web", "im", or "clientname"',
104     
105     index notice_profile_id_idx (profile_id),
106     index notice_created_idx (profile_id),
107     
108     FULLTEXT(content)
109 ) ENGINE=MyISAM;
110
111 create table notice_source (
112      code varchar(8) primary key not null comment 'source code',
113      name varchar(255) not null comment 'name of the source',
114      url varchar(255) not null comment 'url to link to',
115      created datetime not null comment 'date this record was created',
116      modified timestamp comment 'date this record was modified'
117 ) ENGINE=MyISAM;
118
119 create table reply (
120
121     notice_id integer not null comment 'notice that is the reply' references notice (id),
122     profile_id integer not null comment 'profile replied to' references profile (id),
123     modified timestamp not null comment 'date this record was modified',
124     replied_id integer comment 'notice replied to (not used, see notice.reply_to)',
125
126     constraint primary key (notice_id, profile_id),
127     index reply_notice_id_idx (notice_id),
128     index reply_profile_id_idx (profile_id),
129     index reply_replied_id_idx (replied_id)
130
131 ) ENGINE=MyISAM;
132
133 /* tables for OAuth */
134
135 create table consumer (
136     consumer_key varchar(255) primary key comment 'unique identifier, root URL',
137     seed char(32) not null comment 'seed for new tokens by this consumer',
138
139     created datetime not null comment 'date this record was created',
140     modified timestamp comment 'date this record was modified'
141 ) ENGINE=MyISAM;
142
143 create table token (
144     consumer_key varchar(255) not null comment 'unique identifier, root URL' references consumer (consumer_key),
145     tok char(32) not null comment 'identifying value',
146     secret char(32) not null comment 'secret value',
147     type tinyint not null default 0 comment 'request or access',
148     state tinyint default 0 comment 'for requests; 0 = initial, 1 = authorized, 2 = used',
149
150     created datetime not null comment 'date this record was created',
151     modified timestamp comment 'date this record was modified',
152
153     constraint primary key (consumer_key, tok)
154 ) ENGINE=MyISAM;
155
156 create table nonce (
157     consumer_key varchar(255) not null comment 'unique identifier, root URL',
158     tok char(32) not null comment 'identifying value',
159     nonce char(32) not null comment 'nonce',
160     ts datetime not null comment 'timestamp sent',
161
162     created datetime not null comment 'date this record was created',
163     modified timestamp comment 'date this record was modified',
164
165     constraint primary key (consumer_key, tok, nonce),
166     constraint foreign key (consumer_key, tok) references token (consumer_key, tok)
167 ) ENGINE=MyISAM;
168
169 /* One-to-many relationship of user to openid_url */
170
171 create table user_openid (
172     canonical varchar(255) primary key comment 'Canonical true URL',
173     display varchar(255) not null unique key comment 'URL for viewing, may be different from canonical',
174     user_id integer not null comment 'user owning this URL' references user (id),
175     created datetime not null comment 'date this record was created',
176     modified timestamp comment 'date this record was modified',
177
178     index user_openid_user_id_idx (user_id)
179 ) ENGINE=MyISAM;
180
181 /* These are used by JanRain OpenID library */
182
183 create table oid_associations (
184     server_url BLOB,
185     handle VARCHAR(255) character set latin1,
186     secret BLOB,
187     issued INTEGER,
188     lifetime INTEGER,
189     assoc_type VARCHAR(64),
190     PRIMARY KEY (server_url(255), handle)
191 ) ENGINE=MyISAM;
192
193 create table oid_nonces (
194     server_url VARCHAR(2047),
195     timestamp INTEGER,
196     salt CHAR(40),
197     UNIQUE (server_url(255), timestamp, salt)
198 ) ENGINE=MyISAM;
199
200 create table confirm_address (
201     code varchar(32) not null primary key comment 'good random code',
202     user_id integer not null comment 'user who requested confirmation' references user (id),
203     address varchar(255) not null comment 'address (email, Jabber, SMS, etc.)',
204     address_extra varchar(255) not null comment 'carrier ID, for SMS',
205     address_type varchar(8) not null comment 'address type ("email", "jabber", "sms")',
206     claimed datetime comment 'date this was claimed for queueing',
207     sent datetime comment 'date this was sent for queueing',
208     modified timestamp comment 'date this record was modified'
209 ) ENGINE=MyISAM;
210
211 create table remember_me (
212     code varchar(32) not null primary key comment 'good random code',
213     user_id integer not null comment 'user who is logged in' references user (id),
214     modified timestamp comment 'date this record was modified'
215 ) ENGINE=MyISAM;
216
217 create table queue_item (
218
219     notice_id integer not null primary key comment 'notice queued' references notice (id),
220     transport varchar(8) not null comment 'queue for what? "email", "jabber", "sms", "irc", ...',
221     created datetime not null comment 'date this record was created',
222     claimed datetime comment 'date this item was claimed',
223
224     index queue_item_created_idx (created)
225
226 ) ENGINE=MyISAM;
227
228 /* Hash tags */
229 create table notice_tag (
230     tag varchar( 64 ) not null comment 'hash tag associated with this notice',
231     notice_id integer not null comment 'notice tagged' references notice (id),
232     created datetime not null comment 'date this record was created',
233
234     constraint primary key (tag, notice_id),
235     index notice_tag_created_idx (created)
236 ) ENGINE=MyISAM;