| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class SH4_Conf_Migration |
| 3 |
{ |
| 4 |
public $dbForge; |
| 5 |
public $migrationService; |
| 6 |
|
| 7 |
public function __construct( |
| 8 |
HC3_Hooks $hooks, |
| 9 |
HC3_MigrationService $migrationService, |
| 10 |
?HC3_Database_DbForge $dbForge = null |
| 11 |
) |
| 12 |
{ |
| 13 |
$this->dbForge = $dbForge; |
| 14 |
$this->migrationService = $migrationService; |
| 15 |
} |
| 16 |
|
| 17 |
public function up() |
| 18 |
{ |
| 19 |
$currentVersion = $this->migrationService->getVersion( 'conf' ); |
| 20 |
|
| 21 |
if( $currentVersion < 1 ){ |
| 22 |
$this->version1(); |
| 23 |
$this->migrationService->saveVersion( 'conf', 1 ); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
public function version1() |
| 28 |
{ |
| 29 |
if( $this->dbForge ){ |
| 30 |
$this->dbForge->add_field( |
| 31 |
array( |
| 32 |
'id' => array( |
| 33 |
'type' => 'INT', |
| 34 |
'null' => FALSE, |
| 35 |
'unsigned' => TRUE, |
| 36 |
'auto_increment' => TRUE |
| 37 |
), |
| 38 |
'name' => array( |
| 39 |
'type' => 'VARCHAR(255)', |
| 40 |
'null' => FALSE, |
| 41 |
), |
| 42 |
'value' => array( |
| 43 |
'type' => 'TEXT', |
| 44 |
'null' => TRUE, |
| 45 |
), |
| 46 |
) |
| 47 |
); |
| 48 |
$this->dbForge->add_key('id', TRUE); |
| 49 |
$this->dbForge->create_table('conf'); |
| 50 |
} |
| 51 |
} |
| 52 |
} |