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