diff --git a/bin/schedule_building.pl b/bin/schedule_building.pl index 2a414ba0..50de5b14 100644 --- a/bin/schedule_building.pl +++ b/bin/schedule_building.pl @@ -53,7 +53,18 @@ if ($initialize) { # existing jobs out('Reinitializing all jobs'); out('Deleting existing jobs'); - my $schedule_rs = Lacuna->db->resultset('Schedule')->search; + # Only delete the Schedule rows this script owns and is about to + # recreate below. A blanket ->search (no filter) here would also wipe + # out entries owned by other scheduler processes (e.g. the 'arrive' + # rows created by schedule_ship_arrival.pl for Travelling ships), + # deleting their beanstalk jobs along with them with nothing left to + # recreate those jobs, since this script never re-adds 'arrive' rows. + my $schedule_rs = Lacuna->db->resultset('Schedule')->search({ + -or => [ + { parent_table => 'Building' }, + { parent_table => 'Ships', task => 'finish_construction' }, + ], + }); while (my $schedule = $schedule_rs->next) { # note. deleting the DB entry also deletes the entry on beanstalk $schedule->delete;