0
不刪除數據,我有以下遷移:onDelete(「串聯」)上的數據透視表
public function up()
{
Schema::create('topics_to_subscriptions', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->integer('topic_id')->unsigned();
$table->integer('subscription_id')->unsigned();
$table->foreign('topic_id')->references('id')->on('topics')->onDelete('cascade');
$table->foreign('subscription_id')->references('id')->on('subscriptions')->onDelete('cascade');
});
}
我undersatnding是使用onDelete('cascade')
的時候,如果我刪除訂閱,則所有相關的TopicsToSubscriptions
將被刪除。
當我運行App\Subscription::truncate();
所有訂閱從subscriptions
表正確刪除,但沒有數據從topics_to_subscriptions
刪除。我究竟做錯了什麼?