suppress_errors( true ); try { foreach ( Schema::operatingSchedule( $wpdb ) as $table => $sql ) { $exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table ) ) ); if ( $wpdb->last_error ) { throw new RuntimeException( __( 'ABeCe Booking database migration failed. Existing data has been retained.', 'abece-booking' ) ); } // A retry verifies already-created tables rather than altering them. if ( null === $exists ) { dbDelta( $sql ); if ( $wpdb->last_error ) { throw new RuntimeException( __( 'ABeCe Booking database migration failed. Existing data has been retained.', 'abece-booking' ) ); } } Schema::verify( $wpdb, $table, $sql ); } } finally { $wpdb->suppress_errors( $previous ); } } }