title: Why does Doctrine 2 migration silently fail in Symfony project?
body: <p>My questions are:</p>
  
  <ol>
  <li>Why does the doctrine migration command within Symfony fail to report the SQL error I am listing below</li>
  <li>How can I get it to report such errors, rather than look like it has succeeded.</li>
  </ol>
  
  <p>To be clear - I know why the SQL itself fails. That's the easy part. The silent nature of the failure is the problem.</p>
  
  <p>I have a doctrine migration in a PHP file, as so:</p>
  
  <pre><code>[... boilerplate ...]
  
  public function up(Schema $schema)
  {
      $this-&gt;addSql(&lt;&lt;&lt;SQL
  
      -- This runs fine
      CREATE TABLE [[redacted - this part runs fine]];
  
      -- This fails with a unique key constraint
      INSERT INTO `users_orgs` (`org_id`, `user_id`, `active`)
      SELECT `oid`, `uid`, 1 as `active` FROM `orgs`;
  
      -- Never gets here
      ALTER TABLE `orgs` CHANGE `uid` `primary_user_id` int(11) unsigned DEFAULT NULL;
  
  SQL
      );
  }
  
  [... boilerplate ...]
  </code></pre>
  
  <h2>Actual Result</h2>
  
  <p>The second statement fails because of a unique key constraint (like "Duplicate entry '6-3' for key 'PRIMARY'" - it's a compound key) <em>but the error is not reported</em>. I know it fails because it's clear the final statement never runs, and if I run the offending statement manually, it fails. When I run:</p>
  
  <pre><code>./bin/console doctrine:migrations:migrate
  </code></pre>
  
  <p>From within my Symfony application, thus calling the doctrine migration code, it reports:</p>
  
  <pre><code>$ ./bin/console doctrine:migrations:migrate
  
                  Application Migrations                    
  
  
  WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y
  Migrating up to 20160822090333 from 20160820232349
  
    ++ migrating 20160822090333
  
       -&gt; CREATE TABLE [[redacted - works fine]];
  
  INSERT INTO `users_orgs` (`org_id`, `user_id`, `active`)
  SELECT `oid`, `uid`, 1 as `active` FROM `orgs`;
  
  ALTER TABLE `orgs` CHANGE `uid` `primary_user_id` int(11) unsigned  DEFAULT NULL;
  
  
    ++ migrated (0.1s)
  
    ------------------------
  
    ++ finished in 0.1s
    ++ 1 migrations executed
    ++ 1 sql queries
  </code></pre>
  
  <h2>Expected Result</h2>
  
  <p>I'm expecting it to report an error. As a test, I created a one-column table with a primary key. I tried to insert a record that would generate a unique constraint violation from within a migration. When I executed the migration, doctrine reported this:</p>
  
  <pre><code>Migration 20160908112332 failed during Execution. Error An exception occurred while executing '        insert into FOO values (1)':
  
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'
  </code></pre>
  
  <h2>My configuration</h2>
  
  <p>Here's what I have installed (via composer):</p>
  
  <pre><code>doctrine/annotations                 v1.2.7             Docblock Annotations Parser
  doctrine/cache                       v1.6.0             Caching library offering an object-oriented API for many cache backends
  doctrine/collections                 v1.3.0             Collections Abstraction library
  doctrine/common                      v2.6.1             Common Library for Doctrine projects
  doctrine/dbal                        v2.5.4             Database Abstraction Layer
  doctrine/doctrine-bundle             1.6.4              Symfony DoctrineBundle
  doctrine/doctrine-cache-bundle       1.3.0              Symfony Bundle for Doctrine Cache
  doctrine/doctrine-migrations-bundle  v1.2.0             Symfony DoctrineMigrationsBundle
  doctrine/inflector                   v1.1.0             Common String Manipulations with regard to casing and singular/plural rules.
  doctrine/lexer                       v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent Pa...
  doctrine/migrations                  1.4.1              Database Schema migrations using Doctrine DBAL
  symfony/symfony                      v3.0.9
  </code></pre>
  
  <p>MySQL:</p>
  
  <pre><code>mysql Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using  EditLine wrapper
  </code></pre>
  
  <h2>What I've tried</h2>
  
  <p>I have searched "silent doctrine failure", "silent doctrine migration failure" on google and here, and I've not seen anything. Any insight would be appreciated.</p>