文档给出的方法非常难以控制,实际上他是有正常用法的,只是文档可能为了卖钱没有写明
正确示例如下,这样编辑器就会有提示了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| use think\migration\db\Column; use think\migration\Migrator;
class Department extends Migrator { public function change() { $this->table('department') ->setEngine('InnoDB') ->setCollation('utf8mb4_general_ci') ->addColumn(Column::string('name', 255)->setComment('部门名称')) ->addColumn(Column::string('parentid', 255)->setComment('上级部门id')) ->addColumn(Column::integer('order')->setComment('排序')) ->addColumn(Column::json('department_leader')->setComment('部门领导')) ->create(); } }
|