/* local and remote users have profiles */\r
\r
+create sequence profile_seq;\r
create table profile (\r
- id serial primary key /* comment 'unique identifier' */,\r
+ id bigint default nextval('profile_seq') primary key /* comment 'unique identifier' */,\r
nickname varchar(64) not null /* comment 'nickname or username' */,\r
fullname varchar(255) /* comment 'display name' */,\r
profileurl varchar(255) /* comment 'URL, cached so we dont regenerate' */,\r
);\r
create index avatar_profile_id_idx on avatar using btree(profile_id);\r
\r
+create sequence sms_carrier_seq;\r
create table sms_carrier (\r
- id serial primary key /* comment 'primary key for SMS carrier' */,\r
+ id bigint default nextval('sms_carrier_seq') primary key /* comment 'primary key for SMS carrier' */,\r
name varchar(64) unique /* comment 'name of the carrier' */,\r
email_pattern varchar(255) not null /* comment 'sprintf pattern for making an email address from a phone number' */,\r
created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,\r
create index subscription_subscriber_idx on subscription using btree(subscriber);\r
create index subscription_subscribed_idx on subscription using btree(subscribed);\r
\r
+create sequence notice_seq;\r
create table notice (\r
\r
- id serial primary key /* comment 'unique identifier' */,\r
+ id bigint default nextval('notice_seq') primary key /* comment 'unique identifier' */,\r
profile_id integer not null /* comment 'who made the update' */ references profile (id) ,\r
uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */,\r
content varchar(140) /* comment 'update content' */,\r
create table nonce (\r
consumer_key varchar(255) not null /* comment 'unique identifier, root URL' */,\r
tok char(32) not null /* comment 'identifying value' */,\r
- nonce char(32) not null /* comment 'nonce' */,\r
+ nonce char(32) null /* comment 'buggy old value, ignored */,\r
ts integer not null /* comment 'timestamp sent' values are epoch, and only used internally */,\r
\r
created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,\r
modified timestamp /* comment 'date this record was modified' */,\r
\r
- primary key (consumer_key, tok, nonce),\r
- foreign key (consumer_key, tok) references token (consumer_key, tok)\r
+ primary key (consumer_key, ts, nonce)\r
);\r
\r
/* One-to-many relationship of user to openid_url */\r
noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */,\r
friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */, \r
profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */,\r
+ last_noticesync timestamp default null /* comment 'last time notices were imported' */,\r
+ last_friendsync timestamp default null /* comment 'last time friends were imported' */,\r
created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,\r
modified timestamp /* comment 'date this record was modified' */,\r
\r
create index invitation_address_idx on invitation using btree(address,address_type);\r
create index invitation_user_id_idx on invitation using btree(user_id);\r
\r
+create sequence message_seq;\r
create table message (\r
\r
- id serial primary key /* comment 'unique identifier' */,\r
+ id bigint default nextval('message_seq') primary key /* comment 'unique identifier' */,\r
uri varchar(255) unique /* comment 'universally unique identifier' */,\r
from_profile integer not null /* comment 'who the message is from' */ references profile (id),\r
to_profile integer not null /* comment 'who the message is to' */ references profile (id),\r
\r
);\r
\r
+create sequence user_group_seq;\r
create table user_group (\r
\r
- id serial primary key /* comment 'unique identifier' */,\r
+ id bigint default nextval('user_group_seq') primary key /* comment 'unique identifier' */,\r
\r
nickname varchar(64) unique /* comment 'nickname for addressing' */,\r
fullname varchar(255) /* comment 'display name' */,\r
);\r
create index group_inbox_created_idx on group_inbox using btree(created);\r
\r
+\r
+/*attachments and URLs stuff */\r
+create sequence file_seq;\r
+create table file (\r
+ id bigint default nextval('file_seq') primary key /* comment 'unique identifier' */,\r
+ url varchar(255) unique, \r
+ mimetype varchar(50), \r
+ size integer, \r
+ title varchar(255), \r
+ date integer(11), \r
+ protected integer(1)\r
+);\r
+\r
+create sequence file_oembed_seq;\r
+create table file_oembed (\r
+ id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,\r
+ file_id bigint unique,\r
+ version varchar(20),\r
+ type varchar(20),\r
+ provider varchar(50),\r
+ provider_url varchar(255),\r
+ width integer,\r
+ height integer,\r
+ html text,\r
+ title varchar(255),\r
+ author_name varchar(50), \r
+ author_url varchar(255), \r
+ url varchar(255), \r
+);\r
+\r
+create sequence file_redirection_seq;\r
+create table file_redirection (\r
+ id bigint default nextval('file_redirection_seq') primary key /* comment 'unique identifier' */,\r
+ url varchar(255) unique, \r
+ file_id bigint, \r
+ redirections integer, \r
+ httpcode integer\r
+);\r
+\r
+create sequence file_thumbnail_seq;\r
+create table file_thumbnail (\r
+ id bigint default nextval('file_thumbnail_seq') primary key /* comment 'unique identifier' */,\r
+ file_id bigint unique, \r
+ url varchar(255) unique, \r
+ width integer, \r
+ height integer \r
+);\r
+\r
+create sequence file_to_post_seq;\r
+create table file_to_post (\r
+ id bigint default nextval('file_to_post_seq') primary key /* comment 'unique identifier' */,\r
+ file_id bigint, \r
+ post_id bigint, \r
+\r
+ unique(file_id, post_id)\r
+);\r
+\r
+\r
/* Textsearch stuff */\r
\r
create index textsearch_idx on profile using gist(textsearch);\r