自定义行为的原则迁移表创建

时间:2011-12-23 14:43:59

标签: doctrine migration symfony-1.4 behavior

我已经创建了自定义doctrine(1.2)行为,它应该为模型创建表格(非常类似于i18n行为)。我在schema.sql中看到这个表,如果我执行它一切都很好,但是如果我的迁移是差异的话,那就不是这样的表(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());
  }
}

1 个答案:

答案 0 :(得分:0)

解决!

由于命令“php symfony doctrine:build-model”而出现问题。 所以,如果你遇到同样的问题,你应该:

  1. 从架构中删除您的行为。
  2. 执行“php symfony doctrine:build-model”。
  3. 将您的行为添加到架构。
  4. 运行“php symfony doctrine:generate-migrations-diff”。
  5. CHEARS! %)