]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - db/laconica.sql
cc475e4cfcf523c39e79541ec3d544e419e4935e
[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     sms varchar(64) unique key comment 'sms phone number',
49     carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
50     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
51     created datetime not null comment 'date this record was created',
52     modified timestamp comment 'date this record was modified'
53 ) ENGINE=InnoDB;
54
55 /* remote people */
56
57 create table remote_profile (
58     id integer primary key comment 'foreign key to profile table' references profile (id),
59     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
60     postnoticeurl varchar(255) comment 'URL we use for posting notices',
61     updateprofileurl varchar(255) comment 'URL we use for updates to this profile',
62     created datetime not null comment 'date this record was created',
63     modified timestamp comment 'date this record was modified'
64 ) ENGINE=InnoDB;
65
66 create table subscription (
67     subscriber integer not null comment 'profile listening',
68     subscribed integer not null comment 'profile being listened to',
69     token varchar(255) comment 'authorization token',
70     secret varchar(255) comment 'token secret',
71     created datetime not null comment 'date this record was created',
72     modified timestamp comment 'date this record was modified',
73
74     constraint primary key (subscriber, subscribed),
75     index subscription_subscriber_idx (subscriber),
76     index subscription_subscribed_idx (subscribed)
77 ) ENGINE=InnoDB;
78
79 create table notice (
80     id integer auto_increment primary key comment 'unique identifier',
81     profile_id integer not null comment 'who made the update' references profile (id),
82     uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
83     content varchar(140) comment 'update content',
84     /* XXX: cache rendered content. */
85     url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
86     created datetime not null comment 'date this record was created',
87     modified timestamp comment 'date this record was modified',
88
89     index notice_profile_id_idx (profile_id)
90 ) ENGINE=InnoDB;
91
92 /* tables for OAuth */
93
94 create table consumer (
95     consumer_key varchar(255) primary key comment 'unique identifier, root URL',
96     seed char(32) not null comment 'seed for new tokens by this consumer',
97     
98     created datetime not null comment 'date this record was created',
99     modified timestamp comment 'date this record was modified'
100 ) ENGINE=InnoDB;
101
102 create table token (
103     consumer_key varchar(255) not null comment 'unique identifier, root URL' references consumer (consumer_key),
104     tok char(32) not null comment 'identifying value',
105     secret char(32) not null comment 'secret value',
106     type tinyint not null default 0 comment 'request or access',
107     state tinyint default 0 comment 'for requests; 0 = initial, 1 = authorized, 2 = used',
108     
109     created datetime not null comment 'date this record was created',
110     modified timestamp comment 'date this record was modified',
111     
112     constraint primary key (consumer_key, tok)
113 ) ENGINE=InnoDB;
114
115 create table nonce (
116     consumer_key varchar(255) not null comment 'unique identifier, root URL',
117     tok char(32) not null comment 'identifying value',
118     nonce char(32) not null comment 'nonce',
119     ts datetime not null comment 'timestamp sent',
120     
121     created datetime not null comment 'date this record was created',
122     modified timestamp comment 'date this record was modified',
123     
124     constraint primary key (consumer_key, tok, nonce),
125     constraint foreign key (consumer_key, tok) references token (consumer_key, tok)
126 ) ENGINE=InnoDB;
127
128 /* One-to-many relationship of user to openid_url */
129
130 create table user_openid (
131     canonical varchar(255) primary key comment 'Canonical true URL',
132     display varchar(255) not null unique key comment 'URL for viewing, may be different from canonical',
133     user_id integer not null comment 'user owning this URL' references user (id),
134     created datetime not null comment 'date this record was created',
135     modified timestamp comment 'date this record was modified',
136     
137     index user_openid_user_id_idx (user_id)
138 ) ENGINE=InnoDB;
139
140 /* These are used by JanRain OpenID library */
141
142 create table oid_associations (
143     server_url BLOB,
144     handle VARCHAR(255),
145     secret BLOB,
146     issued INTEGER,
147     lifetime INTEGER,
148     assoc_type VARCHAR(64),
149     PRIMARY KEY (server_url(255), handle)
150 ) ENGINE=InnoDB;
151
152 create table oid_nonces (
153     server_url VARCHAR(2047),
154     timestamp INTEGER,
155     salt CHAR(40),
156     UNIQUE (server_url(255), timestamp, salt)
157 ) ENGINE=InnoDB;
158
159 create table confirm_address (
160     code varchar(32) not null primary key comment 'good random code',
161     user_id integer not null comment 'user who requested confirmation' references user (id),
162     address varchar(255) not null comment 'address (email, Jabber, SMS, etc.)',
163     address_extra varchar(255) not null comment 'carrier ID, for SMS',
164     address_type varchar(8) not null comment 'address type ("email", "jabber", "sms")',
165     modified timestamp comment 'date this record was modified'
166 ) ENGINE=InnoDB;