我用CreateNewsTable migratin创建了新闻表。 CreateNewsTable迁移代码是:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNewsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('news', function (Blueprint $table) {
$table->string('author');
$table->string('title');
$table->string('title_image_path');
$table->string('summary');
$table->text('body');
$table->bigInteger('timestamp');
$table->boolean('published');
$table->primary(['author', 'title', 'timestamp']);
$table->foreign('author')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('news');
}
}
现在我想删除外键约束,但我不知道外键约束的名称。 请帮帮我。谢谢你的回答。
答案 0 :(得分:0)
您可以在表INFORMATION_SCHEMA
KEY_COLUMN_USAGE
中找到外键
例如,要查找表news
的外键:
SELECT * FROM information_schema.KEY_COLUMN_USAGE where TABLE_NAME = 'news';
外键的名称位于名为CONSTRAINT_NAME