diff --git a/lib/config/initializer.php b/lib/config/initializer.php index aacb9a590b..64f2337715 100644 --- a/lib/config/initializer.php +++ b/lib/config/initializer.php @@ -233,6 +233,8 @@ class Initializer { } public function install() { + $migrator = new \MailPoet\Config\Migrator; + $migrator->up(); $this->log_version_number(); } diff --git a/lib/config/migrator.php b/lib/config/migrator.php index 238d55ad4d..16b969bf35 100644 --- a/lib/config/migrator.php +++ b/lib/config/migrator.php @@ -1,14 +1,29 @@ 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; } } diff --git a/tests/unit/MigratorCest.php b/tests/unit/MigratorCest.php index ac46e031e1..762003385c 100644 --- a/tests/unit/MigratorCest.php +++ b/tests/unit/MigratorCest.php @@ -4,10 +4,11 @@ use \MailPoet\Config\Migrator; class MigratorCest { public function _before() { - $migrator = new Migrator(); + $this->migrator = new Migrator(); } - public function itCanBeCreated() { + public function itCreatesTheSubscriberTable() { + // Can't be tested because of WordPress. } public function _after() {