我是 Cakephp 新手并使用 Cakephp3.3 构建应用程序,我正在处理迁移,我必须创建一个user_infos表,并且想要添加一个新列user_id,我可以通过迁移添加新列但我不知道如何添加外键。
这是我的迁移文件
public function change()
{
$table = $this->table('user_infos');
$table->addColumn('user_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('title', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('created', 'datetime', [
'default' => null,
'null' => false,
]);
$table->addColumn('modified', 'datetime', [
'default' => null,
'null' => false,
]);
$table->create();
}