Migrator is now able to create real tables.
Because of how WordPress and the dbDelta function works, it's basically impossile to test it with Unit testing. We'll have to make sure we properly test this in acceptance testing.
This commit is contained in:
@@ -1,14 +1,29 @@
|
||||
<?php
|
||||
namespace MailPoet\Config;
|
||||
use \MailPoet\Config\Env;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
|
||||
class Migrator {
|
||||
function __construct() {
|
||||
$this->prefix = \MailPoet\Config\Env::$db_prefix;
|
||||
$this->prefix = Env::$db_prefix . 'mailpoet_';
|
||||
$this->charset = Env::$db_charset;
|
||||
}
|
||||
|
||||
function up() {
|
||||
global $wpdb;
|
||||
dbDelta($this->subscriber());
|
||||
}
|
||||
|
||||
function subscriber() {
|
||||
$table = $this->prefix . 'subscriber';
|
||||
$sql = "CREATE TABLE " . $table . " (
|
||||
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
||||
name text NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);";
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user