database: avoid needlessly incrementing backends.id

This commit is contained in:
Birte Kristina Friesel 2024-08-12 18:08:41 +02:00
parent 9dc5d26380
commit e2b5365810
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA

View file

@ -2815,17 +2815,27 @@ sub sync_stations {
sub sync_backends {
my ($db) = @_;
for my $service ( Travel::Status::DE::HAFAS::get_services() ) {
$db->insert(
my $present = $db->select(
'backends',
'count(*) as count',
{
iris => 0,
hafas => 1,
efa => 0,
ris => 0,
name => $service->{shortname},
},
{ on_conflict => undef }
);
name => $service->{shortname}
}
)->hash->{count};
if ( not $present ) {
$db->insert(
'backends',
{
iris => 0,
hafas => 1,
efa => 0,
ris => 0,
name => $service->{shortname},
},
{ on_conflict => undef }
);
}
}
$db->update( 'schema_version',