From 7f50e9992246116abbc9145cc56b92595ae1b1cd Mon Sep 17 00:00:00 2001 From: Szymon Porwolik Date: Tue, 23 Sep 2025 10:41:40 +0200 Subject: [PATCH] Added error handling for the migration - new cron job will be added only if it was not added before. --- application/migrations/257_add_cron_hamqsl.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/application/migrations/257_add_cron_hamqsl.php b/application/migrations/257_add_cron_hamqsl.php index d81612878..9c955e74a 100644 --- a/application/migrations/257_add_cron_hamqsl.php +++ b/application/migrations/257_add_cron_hamqsl.php @@ -19,7 +19,15 @@ class Migration_add_cron_hamqsl extends CI_Migration { 'next_run' => null ) ); - $this->db->insert_batch('cron', $data); + + // Check if the cron job already exists + $this->db->where('id', 'update_update_hamqsl'); + $query = $this->db->get('cron'); + + if ($query->num_rows() == 0) { + // Insert the cron job only if it does not exist + $this->db->insert_batch('cron', $data); + } } }