title: How to check if mongo collection exists while migating in laravel 5.6?
body: <p>I am using laravel 5.6, mongodb and mysql in one of my project. I used jessengers mongodb package and through which I created schema for my 3 collections, though mongodb is schema less database but for documentation purposes I created schema. one of the example is:</p>
  
  <pre><code>&lt;?php
  
  use Jenssegers\Mongodb\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateChatMessagesTable extends Migration
  {
  
      /**
       * The name of the database connection to use.
       *
       * @var string
       */
      protected $connection = 'mongodb';
  
  
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::connection($this-&gt;connection)-&gt;create('chat_messages', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;integer('user_id');
              $table-&gt;integer('trade_id');
              $table-&gt;tinyInteger('type')-&gt;default('1');
              $table-&gt;text('content');
              $table-&gt;integer('recipient_id');
              $table-&gt;timestamp('recipient_read_at')-&gt;nullable();
              $table-&gt;timestamp('created_at')-&gt;nullable();
              $table-&gt;tinyInteger('status')-&gt;default('1');
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::connection($this-&gt;connection)
              -&gt;table('chat_messages', function (Blueprint $collection)
              {
                  $collection-&gt;drop();
              });
      }
  }
  </code></pre>
  
  <p>here the problem is whenever I run <code>php artisan migrate:fresh</code> command it gives me an error like <code>collection already exists</code>. I need to check,  especially for mongodb, that if collection exists, then do not migrate the collection again.</p>
  
  <p>I guessed that I should run a query like</p>
  
  <pre><code>if(true == ChatMessage::get()){
  //do not run the migration
  } else{
  //continue the migration
  }
  </code></pre>
  
  <p>in migration file only, but I never tried for this way, I kept it for last resolution. Please guide and help me.</p>