title: Laravel Eloquent truncate - Foreign key constraint
body: <p>I am having some issues with deleting data using Laravel 5. I seem to be stuck on a 'foreign key constraint', while I don't see why.</p>
  <p>In my current database model I have a datapoints table, which has a foreign key to the sensors table (datapoints.sensors_id -&gt; sensor.id).</p>
  <p>The code I am trying:</p>
  <pre><code>Route::get('/truncateData', function() {
      DB::table('datapoints')-&gt;truncate();
      DB::table('sensors')-&gt;truncate();
      return 'Done...';
  });
  </code></pre>
  <p>The result:</p>
  <blockquote>
  <p>SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot
  truncate a table referenced in a foreign key constraint
  (<code>alerting</code>.<code>datapoints</code>, CONSTRAINT <code>datapoints_sensor_id_foreign</code>
  FOREIGN KEY (<code>sensor_id</code>) REFERENCES <code>alerting</code>.<code>sensors</code> (<code>id</code>))
  (SQL: truncate <code>sensors</code>)</p>
  </blockquote>
  <p>I would understand this constraint if the order would be inverse (first deleting sensors), but when datapoints is empty, there should be no problem deleting sensors? I have also tried:</p>
  <pre><code>DB::table('datapoints')-&gt;delete();
  DB::table('sensors')-&gt;delete();
  return 'Done...';
  </code></pre>
  <p>Lastly I also tried adding explicitly 'DB::commit()' between the delete statements, but all return the same result.</p>
  <p>Is this normal behaviour? Am I missing something?</p>