2011-12-23 60 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! %)

相关问题