title: Laravel migration transaction
body: <p>When developing i'm having so many issues with migrations in laravel.</p>
  
  <p>I create a migration. When i finish creating it, there's a small error by the middle of the migration (say, a foreign key constraint) that makes "php artisan migrate" fail. He tells me where the error is, indeed, but then migrate gets to an unconsistent state, where all the modifications to the database made before the error are made, and not the next ones.</p>
  
  <p>This makes that when I fix the error and re-run migrate, the first statement fails, as the column/table is already created/modified. Then the only solution I know is to go to my database and "rollback" everything by hand, which is way longer to do.</p>
  
  <p>migrate:rollback tries to rollback the previous migrations, as the current was not applied succesfully.</p>
  
  <p>I also tried to wrap all my code into a DB::transaction(), but it still doesn't work.</p>
  
  <p>Is there any solution for this? Or i just have to keep rolling things back by hand?
  <br /><br /><br /><br />
  edit, adding an example (not writing Schema builder code, just some kind of pseudo-code):<br />
  Migration1:</p>
  
  <pre><code>Create Table users (id, name, last_name, email)
  </code></pre>
  
  <p>Migration1 executed OK. Some days later we make Migration 2:</p>
  
  <pre><code>Create Table items (id, user_id references users.id)
  Alter Table users make_some_error_here
  </code></pre>
  
  <p>Now what will happen is that migrate will call the first statement and will create the table items with his foreign key to users. Then when he tries to apply the next statement it will fail.</p>
  
  <p>If we fix the make_some_error_here, we can't run migrate because the table "items" it's created. We can't rollback (nor refresh, nor reset), because we can't delete the table users since there's a foreign key constraint from the table items.</p>
  
  <p>Then the only way to continue is to go to the database and delete the table items by hand, to get migrate in a consistent state.</p>