mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-12 20:18:02 -04:00
* `execute_script()` now returns a boolean for error handling. * Added transaction to `Migration_MissingConfigKeys.up()`. * Added logging to various migrations. * Added transaction to `Migration_MissingConfigKeys.up()`. * Added logging to various migrations. * Formatting and function call fixes Fixed a minor formatting issue in the migration helper. Replaced a few remaining error_log() calls. Updated executeScriptWithTransaction() to use log_message() * Function call fix Replaced the last error_log() calls with log_message(). --------- Co-authored-by: Joe Williams <hey-there-joe@outlook.com>
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class Migration_fix_empty_reports extends Migration
|
|
{
|
|
/**
|
|
* Perform a migration step.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
log_message('info', 'Starting migration: Fix empty reports.');
|
|
|
|
$builder = $this->db->table('stock_locations');
|
|
$builder->select('location_name');
|
|
$builder->where('location_id', 1);
|
|
$builder->limit(1);
|
|
$location_name = $builder->get()->getResultArray()[0]['location_name'];
|
|
|
|
$location_name = str_replace(' ', '_', $location_name);
|
|
$builder = $this->db->table('permissions');
|
|
$builder->set('location_id', 1);
|
|
$builder->where('permission_id', 'receivings_' . $location_name);
|
|
$builder->orWhere('permission_id', 'sales_' . $location_name);
|
|
$builder->update();
|
|
|
|
log_message('info', 'Finished migration: Fix empty reports.');
|
|
}
|
|
|
|
/**
|
|
* Revert a migration step.
|
|
*/
|
|
public function down(): void {}
|
|
}
|