X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=db%2Flaconica_pg.sql;h=9882d091a50aed16e0f0caf068ae7c0faa89ff10;hb=28e1c163e3e14b646851d7641c1c8a6a00de8fdc;hp=b7ef57d27f84ef72816a97315908e26a734a38b6;hpb=cfc8a47bf11d4427d0a06d746691cfc92c696837;p=quix0rs-gnu-social.git diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index b7ef57d27f..9882d091a5 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -47,6 +47,9 @@ create table "user" ( email varchar(255) unique /* comment 'email address for password recovery etc.' */, incomingemail varchar(255) unique /* comment 'email address for post-by-email' */, emailnotifysub integer default 1 /* comment 'Notify by email of subscriptions' */, + emailnotifyfav integer default 1 /* comment 'Notify by email of favorites' */, + emailnotifynudge integer default 1 /* comment 'Notify by email of nudges' */, + emailnotifymsg integer default 1 /* comment 'Notify by email of direct messages' */, emailmicroid integer default 1 /* comment 'whether to publish email microid' */, language varchar(50) /* comment 'preferred language' */, timezone varchar(50) /* comment 'timezone' */, @@ -63,6 +66,8 @@ create table "user" ( smsemail varchar(255) /* comment 'built from sms and carrier' */, uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI' */, autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */, + urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */, + inboxed integer default 0 /* comment 'has an inbox been created for this user?' */, created timestamp not null /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */ @@ -83,6 +88,8 @@ create table remote_profile ( create table subscription ( subscriber integer not null /* comment 'profile listening' */, subscribed integer not null /* comment 'profile being listened to' */, + jabber integer default 1 /* comment 'deliver jabber messages' */, + sms integer default 1 /* comment 'deliver sms messages' */, token varchar(255) /* comment 'authorization token' */, secret varchar(255) /* comment 'token secret' */, created timestamp not null /* comment 'date this record was created' */, @@ -139,7 +146,6 @@ create table fave ( notice_id integer not null /* comment 'notice that is the favorite' */ references notice (id), user_id integer not null /* comment 'user who likes this notice' */ references "user" (id) , modified timestamp not null /* comment 'date this record was modified' */, - primary key (notice_id, user_id) ); @@ -218,7 +224,7 @@ create table confirm_address ( code varchar(32) not null primary key /* comment 'good random code' */, user_id integer not null /* comment 'user who requested confirmation' */ references "user" (id), address varchar(255) not null /* comment 'address (email, Jabber, SMS, etc.)' */, - address_extra varchar(255) not null /* comment 'carrier ID, for SMS' */, + address_extra varchar(255) not null default '' /* comment 'carrier ID, for SMS' */, address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms")' */, claimed timestamp /* comment 'date this was claimed for queueing' */, sent timestamp /* comment 'date this was sent for queueing' */, @@ -264,18 +270,30 @@ create table foreign_service ( ); create table foreign_user ( - id int not null /* comment 'unique numeric key on foreign service' */, + id int not null unique /* comment 'unique numeric key on foreign service' */, service int not null /* comment 'foreign key to service' */ references foreign_service(id) , uri varchar(255) not null unique /* comment 'identifying URI' */, nickname varchar(255) /* comment 'nickname on foreign service' */, - user_id int /* comment 'link to user on this system, if exists' */ references "user" (id), - credentials varchar(255) /* comment 'authc credentials, typically a password' */, created timestamp not null /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */, primary key (id, service) ); -create index foreign_user_user_id_idx on foreign_user using btree(user_id); + +create table foreign_link ( + user_id int /* comment 'link to user on this system, if exists' */ references "user" (id), + foreign_id int /* comment 'link' */ references foreign_user (id), + service int not null /* comment 'foreign key to service' */ references foreign_service (id), + credentials varchar(255) /* comment 'authc credentials, typically a password' */, + noticesync int not null default 1 /* comment 'notice synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies' */, + friendsync int not null default 2 /* comment 'friend synchronisation, bit 1 = sync outgoing, bit 2 = sync incoming */, + profilesync int not null default 1 /* comment 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming' */, + created timestamp not null /* comment 'date this record was created' */, + modified timestamp not null /* comment 'date this record was modified' */, + + primary key (user_id,foreign_id,service) +); +create index foreign_user_user_id_idx on foreign_link using btree(user_id); create table foreign_subscription ( service int not null /* comment 'service where relationship happens' */ references foreign_service(id) , @@ -290,7 +308,7 @@ create index foreign_subscription_subscribed_idx on foreign_subscription using b create table invitation ( code varchar(32) not null primary key /* comment 'random code for an invitation' */, - user_id int not null /* comment 'who sent the invitation' */ references user (id), + user_id int not null /* comment 'who sent the invitation' */ references "user" (id), address varchar(255) not null /* comment 'invitation sent to' */, address_type varchar(8) not null /* comment 'address type ("email", "jabber", "sms") '*/, created timestamp not null /* comment 'date this record was created' */ @@ -302,7 +320,7 @@ create index invitation_user_id_idx on invitation using btree(user_id); create table message ( id serial primary key /* comment 'unique identifier' */, - uri varchar(255) unique key /* comment 'universally unique identifier' */, + uri varchar(255) unique /* comment 'universally unique identifier' */, from_profile integer not null /* comment 'who the message is from' */ references profile (id), to_profile integer not null /* comment 'who the message is to' */ references profile (id), content varchar(140) /* comment 'message content' */, @@ -317,6 +335,91 @@ create index message_from_idx on message using btree(from_profile); create index message_to_idx on message using btree(to_profile); create index message_created_idx on message using btree(created); +create table notice_inbox ( + + user_id integer not null /* comment 'user receiving the message' */ references "user" (id), + notice_id integer not null /* comment 'notice received' */ references notice (id), + created timestamp not null /* comment 'date the notice was created' */, + source integer default 1 /* comment 'reason it is in the inbox; 1=subscription' */, + + primary key (user_id, notice_id) +); +create index notice_inbox_notice_id_idx on notice_inbox using btree(notice_id); + +create table profile_tag ( + tagger integer not null /* comment 'user making the tag' */ references "user" (id), + tagged integer not null /* comment 'profile tagged' */ references profile (id), + tag varchar(64) not null /* comment 'hash tag associated with this notice' */, + modified timestamp /* comment 'date the tag was added' */, + + primary key (tagger, tagged, tag) +); +create index profile_tag_modified_idx on profile_tag using btree(modified); +create index profile_tag_tagger_tag_idx on profile_tag using btree(tagger,tag); + +create table profile_block ( + + blocker integer not null /* comment 'user making the block' */ references "user" (id), + blocked integer not null /* comment 'profile that is blocked' */ references profile (id), + modified timestamp /* comment 'date of blocking' */, + + primary key (blocker, blocked) + +); + +create table user_group ( + + id serial primary key /* comment 'unique identifier' */, + + nickname varchar(64) unique /* comment 'nickname for addressing' */, + fullname varchar(255) /* comment 'display name' */, + homepage varchar(255) /* comment 'URL, cached so we dont regenerate' */, + description varchar(140) /* comment 'descriptive biography' */, + location varchar(255) /* comment 'related physical location, if any' */, + + original_logo varchar(255) /* comment 'original size logo' */, + homepage_logo varchar(255) /* comment 'homepage (profile) size logo' */, + stream_logo varchar(255) /* comment 'stream-sized logo' */, + mini_logo varchar(255) /* comment 'mini logo' */, + + created timestamp not null /* comment 'date this record was created' */, + modified timestamp /* comment 'date this record was modified' */ + +); +create index user_group_nickname_idx on user_group using btree(nickname); + +create table group_member ( + + group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id), + profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id), + is_admin integer default 0 /* comment 'is this user an admin?' */, + + created timestamp not null /* comment 'date this record was created' */, + modified timestamp /* comment 'date this record was modified' */, + + primary key (group_id, profile_id) +); + +create table related_group ( + + group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id) , + related_group_id integer not null /* comment 'foreign key to user_group' */ references user_group (id), + + created timestamp not null /* comment 'date this record was created' */, + + primary key (group_id, related_group_id) + +); + +create table group_inbox ( + group_id integer not null /* comment 'group receiving the message' references user_group (id) */, + notice_id integer not null /* comment 'notice received' references notice (id) */, + created timestamp not null /* comment 'date the notice was created' */, + + primary key (group_id, notice_id) +); +create index group_inbox_created_idx on group_inbox using btree(created); + /* Textsearch stuff */ create index textsearch_idx on profile using gist(textsearch);