Files
piratepoet/lib/config/migrator.php
marco ba436ccc42 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.
2015-07-30 20:00:58 +02:00

30 lines
603 B
PHP

<?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 = 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;
}
}