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