Skip to content

Commit

Permalink
wip: clean old wrong entries and create index
Browse files Browse the repository at this point in the history
issue #2122
  • Loading branch information
frankiejol committed Dec 3, 2024
1 parent 8082af0 commit 8de3f95
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1496,9 +1496,29 @@ sub _update_data {
$self->_add_domain_drivers_cpu();
$self->_add_domain_drivers_usb_controller();

$self->_clean_wrong_access_group();
$self->_add_indexes();
}

sub _clean_wrong_access_group($self) {
my $sth = $self->_dbh->prepare(
"SELECT * FROM group_access"
);
my $sth_del = $self->_dbh->prepare(
"DELETE FROM group_access WHERE id=?"
);
my %dupe;
$sth->execute;
while ( my $row = $sth->fetchrow_hashref ) {
next if !$row;
my $key = $row->{id_domain}.":".$row->{id_group}.":".($row->{type} or '');
if ($dupe{$key}++) {
$sth_del->execute($row->{id});
}
}
$sth->finish;
}

sub _install_grants($self) {
if ($CAN_FORK) {
my $pid = fork();
Expand Down Expand Up @@ -1563,6 +1583,7 @@ sub _add_indexes_generic($self) {
]
,group_access => [
"unique (id_domain,name,id_group)"
,"unique (id_domain,id_group,type)"
,"index(id_domain)"
,"index(id_group)"
]
Expand Down

0 comments on commit 8de3f95

Please sign in to comment.