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