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