Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 拉威尔5.5罐';不要放弃外国投资_Laravel_Foreign Keys - Fatal编程技术网

Laravel 拉威尔5.5罐';不要放弃外国投资

Laravel 拉威尔5.5罐';不要放弃外国投资,laravel,foreign-keys,Laravel,Foreign Keys,我的奖杯表格: public function up() { Schema::create('trophies', function (Blueprint $table) { $table->increments('id'); $table->integer('tournament_id')->unsigned()->nullable(); $table->foreign('tournament_id')

我的
奖杯
表格:

public function up()
{
    Schema::create('trophies', function (Blueprint $table) {
        $table->increments('id');

        $table->integer('tournament_id')->unsigned()->nullable();
        $table->foreign('tournament_id')
            ->references('id')
            ->on('tournaments')
            ->onUpdate('cascade')
            ->onDelete('cascade')
        ;

        $table->integer('season_id')->unsigned()->nullable();
        $table->foreign('season_id')
            ->references('id')
            ->on('seasons')
            ->onUpdate('cascade')
            ->onDelete('cascade')
        ;

        $table->integer('user_id')->nullable()->unsigned();
        $table->foreign('user_id')
            ->references('id')
            ->on('users')
            ->onUpdate('cascade')
            ->onDelete('cascade');
        ;

        $table->integer('team_id')->nullable()->unsigned();
        $table->foreign('team_id')
            ->references('id')
            ->on('teams')
            ->onUpdate('cascade')
            ->onDelete('cascade')
        ;
        $table->timestamps();
    });
}
现在我想放下外键
seasure\u id

public function up()
{
    Schema::table('trophies', function (Blueprint $table) {
        $table->dropForeign(['season_id']);
    });
}
运行php artisan migrate时,我收到下一个错误:

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'trophies_season_id_foreign'; check that column/key exists (SQL: alter table `trophies` drop foreign key `trophies_season_id_foreign`)
当我将我的项目从Laravel5.0升级到Laravel5.5时,可能出现了一些问题

在phpMyAdmin中:


试试这个。。。您需要删除关系和列

$table->dropForeign(['season_id']);
$table->dropColumn('season_id');

试试这个。。。您需要删除关系和列

$table->dropForeign(['season_id']);
$table->dropColumn('season_id');
这很有效。但是为什么“奖杯、季节、身份、外国”被重新命名为“奖杯、ibfk 1”


这很有效。但是为什么约束“trophies\u season\u id\u foreign”被重命名为“trophies\u ibfk\u 1”?

你能用phpMyAdmin之类的东西检查外键的实际名称吗?我的错-我没有注意到你使用的是数组版本的
dropForeign
。忽略我的回答。如果您尝试基于字符串的版本,即
$table->dropForeign('tropies\u seasure\u id\u foreign'),它是否有效?你能用phpMyAdmin之类的东西检查外键的实际名称吗?我的错-我没有注意到你使用的是数组版本的
dropForeign
。忽略我的回答。如果您尝试基于字符串的版本,即
$table->dropForeign('tropies\u seasure\u id\u foreign'),它是否有效?您可能是手动添加的吗?Laravel中的命名约定没有改变。没有。我没有。我的迁移是首要问题。但我是在项目在Laravel5.0上时完成的。然后我将项目升级到Laravel5.5。您是否手动添加了它?Laravel中的命名约定没有改变。没有。我没有。我的迁移是首要问题。但我是在项目在Laravel5.0上时完成的。然后我将项目升级到Laravel5.5。
public function up()
{
    Schema::table('trophies', function (Blueprint $table) {
        $table->dropForeign('trophies_ibfk_1');
    });
}