Doctrine 1
  1. Doctrine 1
  2. DC-582

DataDict entry missing for datetime type for MySQL causes migrations to fail due to sql error


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 1.2.0, 1.2.1
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
    • Environment:


      I discovered this whilst trying out migrations via symfony. I added a datetime field to my schema.yml and generated the migrations, but upon running the migration I got the following error:

      SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()' at line 1. Failing Query: "ALTER TABLE order_item ADD purchased_at datetime()"

      The following code causes the failure in the actual migration:

      $this->addColumn('order_item', 'purchased_at', 'datetime', '', array());

      because it generates the following sql:

      ALTER TABLE order_item ADD purchased_at datetime()

      The diff from my patched version which fixes the issue is as follows:

      Index: Doctrine/DataDict/Mysql.php
      — Doctrine/DataDict/Mysql.php (revision 7415)
      +++ Doctrine/DataDict/Mysql.php (working copy)
      @@ -227,6 +227,7 @@
      return 'DATE';
      case 'time':
      return 'TIME';
      + case 'datetime':
      case 'timestamp':
      return 'DATETIME';
      case 'float':

      It's against the following repository file:

      I hope this is useful and gets committed


        Rich Birch created issue -
        Jonathan H. Wage made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]


          • Assignee:
            Jonathan H. Wage
            Rich Birch
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: