48 lines
2.6 KiB
MySQL
48 lines
2.6 KiB
MySQL
|
create table query_documents
|
||
|
(
|
||
|
document_id varchar(26) not null comment 'The unique reference ID of the document (UUID v4)'
|
||
|
primary key,
|
||
|
subject_type varchar(32) default 'RECON' not null comment 'The subject type of the query document',
|
||
|
client_id varchar(36) not null comment 'The ID of the client that submitted the document',
|
||
|
client_signature varchar(36) null comment 'The authorization token signed with the document by the client',
|
||
|
channel_peer varchar(256) null comment 'Optional. The channel that the content was sent on',
|
||
|
from_peer varchar(256) null comment 'Optional. The peer that sent the content',
|
||
|
to_peer varchar(256) null comment 'Optional. The peer that is the intended reciever of the content',
|
||
|
proxy_peer varchar(256) null comment 'Optional. The proxy peer used to send the content, may indicates "from_peer" is the original sender.',
|
||
|
retain tinyint default 0 not null comment 'Indicates if this record should be retained or not',
|
||
|
timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp of the document''s submission (based off the authorization token)',
|
||
|
constraint query_documents_document_id_uindex
|
||
|
unique (document_id),
|
||
|
constraint query_documents_discovered_peers_federated_address_fk
|
||
|
foreign key (channel_peer) references peers (federated_address),
|
||
|
constraint query_documents_discovered_peers_federated_address_fk2
|
||
|
foreign key (from_peer) references peers (federated_address),
|
||
|
constraint query_documents_discovered_peers_federated_address_fk3
|
||
|
foreign key (to_peer) references peers (federated_address),
|
||
|
constraint query_documents_peers_federated_address_fk
|
||
|
foreign key (proxy_peer) references peers (federated_address)
|
||
|
)
|
||
|
comment 'An archive of all the submitted query documents the database received';
|
||
|
|
||
|
create index query_documents_channel_peer_index
|
||
|
on query_documents (channel_peer);
|
||
|
|
||
|
create index query_documents_client_id_index
|
||
|
on query_documents (client_id);
|
||
|
|
||
|
create index query_documents_from_peer_index
|
||
|
on query_documents (from_peer);
|
||
|
|
||
|
create index query_documents_proxy_peer_index
|
||
|
on query_documents (proxy_peer);
|
||
|
|
||
|
create index query_documents_retain_index
|
||
|
on query_documents (retain);
|
||
|
|
||
|
create index query_documents_subject_type_index
|
||
|
on query_documents (subject_type);
|
||
|
|
||
|
create index query_documents_to_peer_index
|
||
|
on query_documents (to_peer);
|
||
|
|