hook_name = $hook_name; $this->entity_repository = $entity_repository; $this->queue_repository = $queue_repository; } /** * Get the plugin version when the changes were made. */ public function get_version(): string { return '3.2.0'; } /** * Run the migration. * * @throws Throwable|Critical_Migration_Exception */ public function run(): void { // Schedule indexing of the sequra_order table. $args = array( $this->hook_name ); if ( ! \wp_next_scheduled( $this->hook_name, $args ) ) { \wp_schedule_event( time(), 'hourly', $this->hook_name, $args ); } // Index tables with almost no data or no data at all (sequra_entity, sequra_queue). $repos = array( $this->entity_repository, $this->queue_repository, ); foreach ( $repos as $repo ) { foreach ( $repo->get_required_indexes() as $index ) { if ( ! $repo->add_index( $index ) ) { throw new Exception( 'Failed to add index ' . \sanitize_key( $index->name ) . ' to table ' . \sanitize_key( $repo->get_table_name() ) ); } } } } }