diff options
Diffstat (limited to 'lib/Travelynx/Command/database.pm')
-rw-r--r-- | lib/Travelynx/Command/database.pm | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index 4389430..ebe9537 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -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', |