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