symfony Doctrine 迁移添加布尔列和字段长度
我有一个 symfony 1.4 项目,我正在通过迁移添加一个新列。 schema.yml 中的新列如下所示:
has_private_data: { type: boolean, notnull: true, default: false }
生成的迁移如下所示:
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Version26 extends Doctrine_Migration_Base
{
public function up()
{
$this->addColumn('device', 'has_private_data', 'boolean', '25', array(
'notnull' => '1',
'default' => '0',
));
$this->addColumn('device_history', 'has_private_data', 'boolean', '25', array(
'notnull' => '1',
'default' => '0',
));
}
public function down()
{
$this->removeColumn('device', 'has_private_data');
$this->removeColumn('device_history', 'has_private_data');
}
}
为什么此布尔字段的长度设置为 25
? (我的后端数据库是MySql。)
I have a symfony 1.4 project and I am adding a new column via a migration. The new column in schema.yml
looks like this:
has_private_data: { type: boolean, notnull: true, default: false }
The migration that gets generated looks like this:
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Version26 extends Doctrine_Migration_Base
{
public function up()
{
$this->addColumn('device', 'has_private_data', 'boolean', '25', array(
'notnull' => '1',
'default' => '0',
));
$this->addColumn('device_history', 'has_private_data', 'boolean', '25', array(
'notnull' => '1',
'default' => '0',
));
}
public function down()
{
$this->removeColumn('device', 'has_private_data');
$this->removeColumn('device_history', 'has_private_data');
}
}
Why it the length of this boolean field being set to 25
? (My backend database is MySql.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忽略这一点就可以拯救你。在
Table.php
的第 1361 行,您可以发现如果类型为 booelan,则length
将固定为1
。You can be save by ignoring that. In doctines
Table.php
on line 1361 you can find that if the type is booelan thelength
will be fixed to1
.