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