迁移我的数据库时出现此错误,下面是我的代码,后面是我在尝试运行迁移时遇到的错误.
码
public function up()
{
Schema::create('meals', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->string('title');
$table->string('body');
$table->string('meal_av');
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->foreign('category_id')
->references('id')
->on('categories')
->onDelete('cascade');
});
}
Run Code Online (Sandbox Code Playgroud)
错误信息
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1005 Can't create table `meal`.`#sql-11d2_1
4` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter
table `meals` add constraint meals_category_id_foreign foreign key (`catego
ry_id`) references `categories` (`id`) on delete cascade)
Run Code Online (Sandbox Code Playgroud) 显示 PHP 配置的最简单方法是什么
phpinfo();
Run Code Online (Sandbox Code Playgroud)
在 Laravel 应用程序中,在开发环境中调试本地 PHP 配置?
背景:
我需要在我的Mac上找出brew将php.ini读取的文件放置在哪里。