Shorten automation table names
[MAILPOET-4465]
This commit is contained in:
@ -14,11 +14,13 @@ class Migrator {
|
||||
|
||||
public function __construct() {
|
||||
global $wpdb;
|
||||
$this->prefix = $wpdb->prefix . 'mailpoet_automation_';
|
||||
$this->prefix = $wpdb->prefix . 'mailpoet_';
|
||||
$this->wpdb = $wpdb;
|
||||
}
|
||||
|
||||
public function createSchema(): void {
|
||||
$this->removeOldSchema();
|
||||
|
||||
$this->runQuery("
|
||||
CREATE TABLE {$this->prefix}workflows (
|
||||
id int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
@ -48,6 +50,7 @@ class Migrator {
|
||||
}
|
||||
|
||||
public function deleteSchema(): void {
|
||||
$this->removeOldSchema();
|
||||
$this->runQuery("DROP TABLE IF EXISTS {$this->prefix}workflows");
|
||||
$this->runQuery("DROP TABLE IF EXISTS {$this->prefix}workflow_runs");
|
||||
|
||||
@ -67,10 +70,16 @@ class Migrator {
|
||||
}
|
||||
|
||||
public function hasSchema(): bool {
|
||||
$pattern = $this->wpdb->esc_like($this->prefix) . '%';
|
||||
$pattern = $this->wpdb->esc_like("{$this->prefix}workflows") . '%';
|
||||
return $this->runQuery("SHOW TABLES LIKE '$pattern'") > 0;
|
||||
}
|
||||
|
||||
private function removeOldSchema(): void {
|
||||
$oldPrefix = $this->wpdb->prefix . 'mailpoet_automation_';
|
||||
$this->runQuery("DROP TABLE IF EXISTS {$oldPrefix}workflows");
|
||||
$this->runQuery("DROP TABLE IF EXISTS {$oldPrefix}workflow_runs");
|
||||
}
|
||||
|
||||
private function runQuery(string $query): int {
|
||||
$this->wpdb->hide_errors();
|
||||
// It's a private method and all Queries in this class are safe
|
||||
|
@ -22,7 +22,7 @@ class WorkflowRunStorage {
|
||||
SubjectLoader $subjectLoader
|
||||
) {
|
||||
global $wpdb;
|
||||
$this->table = $wpdb->prefix . 'mailpoet_automation_workflow_runs';
|
||||
$this->table = $wpdb->prefix . 'mailpoet_workflow_runs';
|
||||
$this->wpdb = $wpdb;
|
||||
$this->subjectLoader = $subjectLoader;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class WorkflowStorage {
|
||||
|
||||
public function __construct() {
|
||||
global $wpdb;
|
||||
$this->table = $wpdb->prefix . 'mailpoet_automation_workflows';
|
||||
$this->table = $wpdb->prefix . 'mailpoet_workflows';
|
||||
$this->wpdb = $wpdb;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user