当我想通过控制台创建新的 table 时如何添加默认值
How can i add default value when i want to create new table via console
我有这样的 shell 命令。请告诉我,我怎样才能为这个查询添加默认值?
bin/cake bake migration CreateProducts name:string description:text created modified
不可以,不支持,列定义语法为:
fieldName:fieldType?[length]:indexType:indexName
如果要指定默认值,则需要使用 addColumn()
方法的 default
选项手动将其添加到迁移文件中,例如:
$table->addColumn('name', 'string', [
'default' => 'default value',
// ...
]);
另见
我有这样的 shell 命令。请告诉我,我怎样才能为这个查询添加默认值?
bin/cake bake migration CreateProducts name:string description:text created modified
不可以,不支持,列定义语法为:
fieldName:fieldType?[length]:indexType:indexName
如果要指定默认值,则需要使用 addColumn()
方法的 default
选项手动将其添加到迁移文件中,例如:
$table->addColumn('name', 'string', [
'default' => 'default value',
// ...
]);
另见