2011-08-09 31 views
2

我有一個symfony 1.4項目,我正在通過遷移添加一個新列。在schema.yml新列如下:symfony原則遷移添加布爾列和字段長度

has_private_data: { type: boolean, notnull: true, default: false } 

獲取生成看起來像這樣的遷移:

<?php 
/** 
* This class has been auto-generated by the Doctrine ORM Framework 
*/ 
class Version26 extends Doctrine_Migration_Base 
{ 
    public function up() 
    { 
     $this->addColumn('device', 'has_private_data', 'boolean', '25', array(
      'notnull' => '1', 
      'default' => '0', 
      )); 
     $this->addColumn('device_history', 'has_private_data', 'boolean', '25', array(
      'notnull' => '1', 
      'default' => '0', 
      )); 
    } 

    public function down() 
    { 
     $this->removeColumn('device', 'has_private_data'); 
     $this->removeColumn('device_history', 'has_private_data'); 
    } 
} 

爲什麼這個布爾字段的長度被設置爲25? (我的後端數據庫是MySql。)

回答

1

您可以通過忽略它來保存。在線1361上的doctines Table.php,你可以發現如果類型是booelan,length將被固定爲1

  case 'boolean': 
       $length = 1; 
+0

感謝您的回覆。你知道我看到的行爲是否是教條中的錯誤或預期的東西? – rlandster