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