| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Migrations\Versions; |
| 4 |
|
| 5 |
use SyncBasalam\Migrations\MigrationInterface; |
| 6 |
|
| 7 |
defined('ABSPATH') || exit; |
| 8 |
|
| 9 |
class Migration_1_7_8 implements MigrationInterface |
| 10 |
{ |
| 11 |
public function up() |
| 12 |
{ |
| 13 |
global $wpdb; |
| 14 |
$tableName = $wpdb->prefix . 'sync_basalam_job_manager'; |
| 15 |
|
| 16 |
$this->addNewColumns($wpdb, $tableName); |
| 17 |
$this->removeProductOperationTypeSetting(); |
| 18 |
} |
| 19 |
|
| 20 |
private function addNewColumns($wpdb, $tableName) |
| 21 |
{ |
| 22 |
$wpdb->query("ALTER TABLE {$tableName} ADD COLUMN attempts TINYINT UNSIGNED NOT NULL DEFAULT 0"); |
| 23 |
$wpdb->query("ALTER TABLE {$tableName} ADD COLUMN max_attempts TINYINT UNSIGNED NOT NULL DEFAULT 3"); |
| 24 |
$wpdb->query("ALTER TABLE {$tableName} ADD COLUMN failed_at INT NULL"); |
| 25 |
} |
| 26 |
|
| 27 |
private function removeProductOperationTypeSetting() |
| 28 |
{ |
| 29 |
$settings = (array) get_option('sync_basalam_settings', []); |
| 30 |
|
| 31 |
if (is_array($settings) && isset($settings['product_operation_type'])) { |
| 32 |
unset($settings['product_operation_type']); |
| 33 |
update_option('sync_basalam_settings', $settings); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|