title: foreign key constraint: cannot drop table because other objects depend on it
body: <p>I'm running migrations on Laravel 5.1 and am switching DBs from Mysql to Postgres. </p>
  
  <p>Typically I could set foreign key checks to 0 prior to running <code>down</code> migrations as such:</p>
  
  <pre><code>- DB::statement('SET FOREIGN_KEY_CHECKS = 0');
  - Do stuff
  - DB::statement('SET FOREIGN_KEY_CHECKS = 1');
  </code></pre>
  
  <p>Postgres does not offer this.</p>
  
  <p>In running down migrations, I get error:</p>
  
  <blockquote>
    <p>Dependent objects still exist: 7 ERROR:  cannot drop table table2 because other objects depend on it  </p>
    
    <p>DETAIL:  constraint table1_table2_table1_id_foreign on table table1_table2 depends on table table2  </p>
    
    <p>HINT:  Use DROP ... CASCADE to drop the dependent objects too. (SQL: drop table "table2")     </p>
  </blockquote>
  
  <p><strong>Question</strong>: This complaint is curious to me as I set <code>-&gt;onDelete('cascade');</code> on the foreign key creations. Why is this happening?</p>
  
  <p><strong>Snippets:</strong></p>
  
  <p>Create Table1 Table:</p>
  
  <pre><code>...
  public function down()
  {
      Schema::drop('table1_table2');
      Schema::drop('table1'); 
  }
  </code></pre>
  
  <p>Create Table2 Table (Called after table 1 migration):</p>
  
  <pre><code>...
  public function down()
  {
      Schema::drop('table2'); 
  }
  </code></pre>
  
  <p>Create Foreign Keys Table (last migration to be called)</p>
  
  <pre><code>public function up()
  {
    Schema::table('table1_table2', function(Blueprint $table)
    {
      $table-&gt;foreign('table1_id')-&gt;references('id')-&gt;on('table1')-&gt;onDelete('cascade');
      $table-&gt;foreign('table2_id')-&gt;references('id')-&gt;on('table2')-&gt;onDelete('cascade');
    });
    ...
   }
  
  public function down()
  {
      ...
      Schema::table('table1_table2', function(Blueprint $table)
      {
          $table-&gt;dropForeign('table1_id');
          $table-&gt;dropForeign('table2_id');
      });
      ...
  }
  </code></pre>