2011-12-23 52 views
0

我已經創建了應該爲模型創建表格的自定義原則(1.2)行爲(非常類似於i18n行爲)。我在schema.sql中看到了這些表,如果我執行它,一切都很好,但如果我的遷移diff(doctrine:generate-migrations-diff),則不會有這樣的表。關於自定義行爲的原則遷移的表格創建

什麼,我做錯了什麼?

class DescriptionableGenerator extends Doctrine_Record_Generator 
{ 
    protected $_options = array(
          'className'  => '%CLASS%Description', 
          'tableName'  => '%TABLE%_description', 
          'fields'   => array(), 
          'generateFiles' => false, 
          'table'   => false, 
          'pluginTable' => false, 
          'children'  => array(), 
          'options'  => array(), 
          'cascadeDelete' => true, 
          'appLevelDelete' => false 
         ); 

    public function __construct(array $options = array()) 
    { 
    $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); 
    } 

    public function buildRelation() 
    { 
    $this->buildForeignRelation('Descriptions'); 
    $this->buildLocalRelation(); 
    } 

    public function setTableDefinition() 
    { 
    $this->hasColumn('lang', 'char', '2', array('notnull' => true)); 
    $this->hasColumn('field', 'string', '255', array('notnull' => true)); 
    $this->hasColumn('title', 'string', '255', array('notnull' => true)); 
    $this->hasColumn('description', 'clob'); 
    $this->hasColumn('compulsory', 'boolean', 1, array('notnull' => true, 'default' => 0)); 

    $this->addListener(new DescriptionableListener()); 
    } 
} 

回答

0

解決!

問題出現在命令「php symfony doctrine:build-model」中。 所以,如果你有同樣的問題,你應該:

  1. 從模式中刪除你的行爲。
  2. 執行「php symfony doctrine:build-model」。
  3. 將您的行爲添加到模式。
  4. 運行「php symfony doctrine:generate-migrations-diff」。

Chears! %)

相關問題