title: What is the difference between database migrations and transactions while unit testing in Lumen?
body: <p>Per the Lumen 5.3 documentation:</p>
  
  <blockquote>
    <p>Using Migrations</p>
    
    <p>One option is to rollback the database after each test and migrate it
    before the next test. Lumen provides a simple DatabaseMigrations trait
    that will automatically handle this for you. Simply use the trait on
    your test class:</p>
  
  <pre><code>&lt;?php
  
  use Laravel\Lumen\Testing\DatabaseMigrations; 
  use Laravel\Lumen\Testing\DatabaseTransactions;
  
  class ExampleTest extends TestCase 
  {
      use DatabaseMigrations;
  
      /**
       * A basic functional test example.
       *
       * @return void
       */
      public function testBasicExample()
      {
          $this-&gt;get('/foo');
      } 
  } 
  </code></pre>
    
    <p>Using Transactions</p>
    
    <p>Another option is to wrap every test case in a database transaction.
    Again, Lumen provides a convenient DatabaseTransactions trait that
    will automatically handle this:</p>
  
  <pre><code>&lt;?php
  
  use Laravel\Lumen\Testing\DatabaseMigrations;
  use Laravel\Lumen\Testing\DatabaseTransactions;
  
  class ExampleTest extends TestCase 
  {
      use DatabaseTransactions;
  
      /**
       * A basic functional test example.
       *
       * @return void
       */
      public function testBasicExample()
      {
          $this-&gt;get('/foo');
      } 
  }
  </code></pre>
  </blockquote>
  
  <p>As you can see the explanation text is nearly identical and the code example is the exact same with the exception of the trait usage. So it is clear to me that the difference lies completely within the way that the framework handles the tests.</p>
  
  <p>What do these do differently and when would you prefer one over the other?</p>
  
  <p>If one difference has to do with database driver I am using MYSQL.</p>