migration lockfile lifetime

This commit is contained in:
github-actions
2024-08-02 11:48:41 +02:00
parent 23a6e231f6
commit 4e034966c2
3 changed files with 54 additions and 3 deletions

View File

@@ -37,5 +37,20 @@ $config['migration_version'] = 211;
$config['migration_path'] = APPPATH . 'migrations/';
/*
|--------------------------------------------------------------------------
| Migration Lockfile
|--------------------------------------------------------------------------
|
| Path to the migration lockfile.
| This lockfile prevents migrations from running twice
|
*/
$config['migration_lockfile'] = sys_get_temp_dir() . '/.migration_running';
// the maximum age of the lockfile in seconds
$config['migration_lf_maxage'] = 30;
/* End of file migration.php */
/* Location: ./application/config/migration.php */

View File

@@ -3,6 +3,7 @@ class Migrate extends CI_Controller {
public function index() {
$this->load->library('Migration');
$this->load->config('migration');
$result = array();
$latest = $this->migration->latest();
@@ -12,7 +13,7 @@ class Migrate extends CI_Controller {
log_message('error', 'Migration failed');
$result['status'] = 'error';
} else {
while (file_exists(APPPATH . 'cache/.migration_running')) {
while (file_exists($this->config->item('migration_lockfile'))) {
sleep(1);
}
$result['status'] = 'success';