| 1 |
<?php namespace Datafeedr\Api\Migrations; |
| 2 |
|
| 3 |
use Datafeedr\Api\Wuwei\Database\Table; |
| 4 |
use Datafeedr\Api\Wuwei\Migrations\Migration_Interface; |
| 5 |
|
| 6 |
class Migration_20180120151532_Add_Networks_Table extends Migration implements Migration_Interface { |
| 7 |
|
| 8 |
public function run() { |
| 9 |
|
| 10 |
$table = new Table( 'datafeedr_networks' ); |
| 11 |
|
| 12 |
if ( $table->exists() ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
$data = [ |
| 17 |
'id INT(11) NOT NULL COMMENT "Affiliate network ID."', |
| 18 |
'name TEXT NOT NULL COMMENT "Affiliate network name."', |
| 19 |
'network_group VARCHAR(100) NOT NULL COMMENT "Affiliate network general group name."', |
| 20 |
'type VARCHAR(10) NOT NULL COMMENT "The type of records this network supports. Either product or coupon."', |
| 21 |
'merchant_count INT(11) NOT NULL DEFAULT "0" COMMENT "The number of merchants supported by this affiliate network."', |
| 22 |
'product_count INT(11) NOT NULL DEFAULT "0" COMMENT "The number of products supported by this affiliate network."', |
| 23 |
'created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT "The timestamp when network was added to this database."', |
| 24 |
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT "The timestamp when network was updated in this database."', |
| 25 |
'deleted_at TIMESTAMP NULL DEFAULT NULL COMMENT "The timestamp if/when network was deleted from this database."', |
| 26 |
'PRIMARY KEY (id)', |
| 27 |
'KEY name (name(100))', |
| 28 |
'KEY network_group (network_group)', |
| 29 |
'KEY type (type)', |
| 30 |
]; |
| 31 |
|
| 32 |
$create_result = $table->create( $data ); |
| 33 |
|
| 34 |
error_log( '$create_result' . ': ' . print_r( $create_result, true ) ); |
| 35 |
} |
| 36 |
} |