表格对于自定义行为的原则迁移 [英] Table creaction on doctrine migration for custom behavior
本文介绍了表格对于自定义行为的原则迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了自定义原则(1.2)行为,它应该为模型创建表(非常类似于i18n行为)。我在schema.sql中看到这个表,如果我执行它,一切都很好,但是如果我的迁移差异(doctrine:generate-migrations-diff),这不是这样的表。
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).
我做错了什么?
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());
}
}
推荐答案
!
由于命令php symfony doctrine:build-model出现问题。
所以,如果你有同样的问题,你应该:
Problem appears due to command "php symfony doctrine:build-model". So, if you have the same problem you should:
- 从模式中删除你的行为。
- 执行php symfony doctrine:build-model。
- 将您的行为添加到模式。
- 运行php symfony doctrine:generate -migrations-diff。
- Remove your behavior from schema.
- Execute "php symfony doctrine:build-model".
- Add your behavior to schema.
- Run "php symfony doctrine:generate-migrations-diff".
Chears! %)
Chears! %)
这篇关于表格对于自定义行为的原则迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文