federationlib/database/anomaly_tracking.sql

24 lines
1.4 KiB
MySQL
Raw Normal View History

2023-06-04 14:23:51 -04:00
create table anomaly_tracking
(
tracking_id varchar(36) default uuid() not null comment 'The UUID V4 Tracking ID for the anomaly'
primary key,
target_peer varchar(256) not null comment 'The target peer to which this anomaly is being tracked to',
event_type varchar(32) not null comment 'The event type that''s being tracked for the target peer',
usage_data mediumblob null comment 'The usage data of the event from the past 48 hours',
last_updated bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this record was last updated',
created_timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this record was first created',
constraint anomaly_tracking_event_type_target_peer_uindex
unique (event_type, target_peer),
constraint anomaly_tracking_target_peer_uindex
unique (target_peer),
constraint anomaly_tracking_tracking_id_uindex
unique (tracking_id),
constraint anomaly_tracking_peers_federated_address_fk
foreign key (target_peer) references peers (federated_address)
)
comment 'This table is used for tracking anomalies for events';
create index anomaly_tracking_event_type_index
on anomaly_tracking (event_type);