Refactor evidence table schema by removing unnecessary constraints and improving primary key definition

This commit is contained in:
netkas 2025-06-05 00:38:08 -04:00
parent 65675f1466
commit 17fcc4321f
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -1,8 +1,7 @@
create table evidence
(
uuid varchar(36) default uuid() not null comment 'The Unique Universal Identifier for the evidence record'
primary key comment 'The Unique Universal Identifier index for the evidence',
blacklist varchar(36) null comment 'Optional. If this evidence caused a blacklist, this would be the evidence related to it',
uuid varchar(36) default uuid() not null comment 'The Unique Universal Identifier index for the evidence'
primary key,
entity varchar(36) not null comment 'The UUID of the entity that this evidence is related to',
operator varchar(36) not null comment 'The operator that submitted the evidence',
confidential tinyint(1) default 0 not null comment 'Default: 0, 1=The evidence and all of it''s attachments is confidential and only operators can view this, 0=The evidence is available for public view',
@ -11,9 +10,6 @@ create table evidence
created timestamp default current_timestamp() not null comment 'The timestamp of the evidence',
constraint evidence_uuid_uindex
unique (uuid) comment 'The Unique Universal Identifier index for the evidence',
constraint evidence_blacklist_uuid_fk
foreign key (blacklist) references blacklist (uuid)
on update cascade on delete set null,
constraint evidence_entities_uuid_fk
foreign key (entity) references entities (uuid)
on update cascade on delete cascade,
@ -23,10 +19,6 @@ create table evidence
)
comment 'Table for housing evidence';
create index evidence_blacklist_index
on evidence (blacklist)
comment 'The Blacklist UUID index';
create index evidence_entity_index
on evidence (entity)
comment 'The index of the entity UUID';