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