federationlib/database/peers.sql
2023-06-23 03:53:47 -04:00

29 lines
No EOL
1.7 KiB
SQL

create table peers
(
federated_address varchar(256) not null comment 'The standard federated address of the peer'
primary key,
client_first_seen varchar(36) not null comment 'The UUID of the client that first discovered the peer',
client_last_seen varchar(36) not null comment 'The UUID of the client that last saw this peer',
active_restriction varchar(36) null comment 'Optional. The UUID of the restriction that is currently active on the peer',
permission_role tinyint default 5 not null comment 'The permission role assigned to the peer',
discovered_timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this peer was first discovered',
seen_timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this peer was last seen',
constraint discovered_peers_federated_address_uindex
unique (federated_address),
constraint discovered_peers_clients_uuid_fk
foreign key (client_first_seen) references clients (uuid),
constraint discovered_peers_clients_uuid_fk2
foreign key (client_last_seen) references clients (uuid),
constraint peers_restrictions_uuid_fk
foreign key (active_restriction) references restrictions (uuid)
)
comment 'The table for housing all the discovered peers';
create index discovered_peers_client_first_seen_index
on peers (client_first_seen);
create index discovered_peers_client_last_seen_index
on peers (client_last_seen);
create index peers_active_restriction_index
on peers (active_restriction);