本文介绍了Laravel Schema Builder更改存储引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改表并将其存储引擎更改为InnoDb.当我运行php artisan migrate时,它完成而没有错误.但是,当我在Sequel Pro中检查存储引擎时,没有任何改变.

I am trying to alter a table and change it's storage engine to InnoDb. When I run php artisan migrate it completes without error. However when I check the storage engine in Sequel Pro, nothing is changed.

public function up()
{
    Schema::table('tests', function(Blueprint $t) {
        $t->engine = 'InnoDB';
        $t->foreign('group_id')->references('id')->on('test_groups')->onDelete('restrict');
    });
}

推荐答案

由于@alexrussell证实了我的信念,因此我几乎可以肯定,只有在使用Schema::create()创建表时,您才能定义存储引擎.
但是,您始终可以将原始SQL用作最后的手段:

Since @alexrussell confirmed my believe, I'm almost certain you can only define the storage engine when you create the table with Schema::create().
However you can always use raw SQL as a last resort:

DB::statement('ALTER TABLE tests ENGINE = InnoDB');

这篇关于Laravel Schema Builder更改存储引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 16:45