Add version check to cron manager

This commit is contained in:
phl0
2024-09-12 16:23:58 +02:00
parent a51094f22e
commit 13bb263bfe
2 changed files with 34 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 217;
$config['migration_version'] = 219;
/*
|--------------------------------------------------------------------------

View File

@@ -0,0 +1,33 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_version_check_to_cron extends CI_Migration {
public function up() {
if ($this->chk4cron('version_check') == 0) {
$data = array(
array(
'id' => 'version_check',
'enabled' => '0',
'status' => 'pending',
'description' => 'Check for new Wavelog releases',
'function' => 'index.php/update/wavelog_update_check',
'expression' => '45 4 * * *',
'last_run' => null,
'next_run' => null
));
$this->db->insert_batch('cron', $data);
}
}
public function down() {
if ($this->chk4cron('version_check') > 0) {
$this->db->query("delete from cron where id='version_check'");
}
}
function chk4cron($cronkey) {
$query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey);
$row = $query->row();
return $row->cid ?? 0;
}
}