Table creaction on doctrine migration for custom behavior

不羁岁月 提交于 2019-12-25 02:15:34

问题


I've created custom doctrine(1.2) behavior which should create tables for models (very simmilar to i18n behavior). I see this tables in schema.sql, and if i execute it everything is fine, but this is no such tables if my migrations diff (doctrine:generate-migrations-diff).

What i'm doing wrong?

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:


Solved!

Problem appears due to command "php symfony doctrine:build-model". So, if you have the same problem you should:

  1. Remove your behavior from schema.
  2. Execute "php symfony doctrine:build-model".
  3. Add your behavior to schema.
  4. Run "php symfony doctrine:generate-migrations-diff".

Chears! %)



来源:https://stackoverflow.com/questions/8617301/table-creaction-on-doctrine-migration-for-custom-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!