Skip to content

Commit

Permalink
Merge pull request #107 from humanmade/remove-nextrun-index
Browse files Browse the repository at this point in the history
Remove nextrun index
  • Loading branch information
roborourke committed Dec 3, 2020
2 parents 771b2e1 + e5d9e9c commit e8b1e9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 1 addition & 2 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ function create_tables() {
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `site` (`site`),
KEY `hook` (`hook`),
KEY `nextrun` (`nextrun`)
KEY `hook` (`hook`)
) ENGINE=InnoDB {$charset_collate};\n";

// TODO: check return value
Expand Down
21 changes: 19 additions & 2 deletions inc/upgrade/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function upgrade_database() {
upgrade_database_3();
}

if ( $database_version < 4 ) {
upgrade_database_4();
}

update_site_option( 'cavalcade_db_version', DATABASE_VERSION );

Job::flush_query_cache();
Expand Down Expand Up @@ -78,8 +82,21 @@ function upgrade_database_3() {

$query = "ALTER TABLE `{$wpdb->base_prefix}cavalcade_jobs`
ADD INDEX `site` (`site`),
ADD INDEX `hook` (`hook`),
ADD INDEX `nextrun` (`nextrun`)";
ADD INDEX `hook` (`hook`)";

$wpdb->query( $query );
}

/**
* Upgrade Cavalcade database tables to version 4.
*
* Remove nextrun index as it negatively affects performance.
*/
function upgrade_database_4() {
global $wpdb;

$query = "ALTER TABLE `{$wpdb->base_prefix}cavalcade_jobs`
DROP INDEX `nextrun`";

$wpdb->query( $query );
}
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace HM\Cavalcade\Plugin;

const DATE_FORMAT = 'Y-m-d H:i:s';
const DATABASE_VERSION = 3;
const DATABASE_VERSION = 4;

require __DIR__ . '/inc/namespace.php';
require __DIR__ . '/inc/class-job.php';
Expand Down

0 comments on commit e8b1e9a

Please sign in to comment.