Doctrine 1
  1. Doctrine 1
  2. DC-1053

Renaming a doctrine 'string' field may result in loss of data as the field's type changes. (MySQL)

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
      None
    • Environment:

      Description

      Consider the following schema:

      schema.yml
      MyTable:
        columns:
          some_text:        string
      

      Doctrine creates the table with:

      CREATE TABLE `my_table` (
        `id` bigint(20) NOT NULL AUTO_INCREMENT,
        `some_text` text,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
      

      Now, the following migration should rename the field from some_text to just_text:

      <?php
      class Version1 extends Doctrine_Migration_Base
      {
          public function up()
          {
              $this->renameColumn('my_table', 'some_text', 'just_text');
          }
      
          public function down()
          {
            $this->renameColumn('my_table', 'just_text', 'some_text');
          }
      }
      

      ...however the field gets renamed and the type becomes VARCHAR(255), as the resulting SHOW CREATE TABLE my_table shows:

      CREATE TABLE `my_table` (
        `id` bigint(20) NOT NULL AUTO_INCREMENT,
        `a_varchar` varchar(255) DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
      

      Causes data in the column greater than 255 bytes to get truncated

        Activity

        Ben Lancaster created issue -
        Ben Lancaster made changes -
        Field Original Value New Value
        Summary Renaming a doctrine 'string' field results in loss of data as the field's type changes. (MySQL) Renaming a doctrine 'string' field may result in loss of data as the field's type changes. (MySQL)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ben Lancaster
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: