【问题标题】:Laravel Schema Builder alter storage engineLaravel Schema Builder 改变存储引擎
【发布时间】:2015-02-14 12:14:10
【问题描述】:

我正在尝试更改一个表并将其存储引擎更改为InnoDb。当我运行php artisan migrate 时,它会毫无错误地完成。但是,当我在 Sequel Pro 中检查存储引擎时,什么都没有改变。

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

【问题讨论】:

  • 我不确定,但我认为您只能在创建表时定义它,之后不能更改它。
  • 很确定@lukasgeiter 在那里是正确的。

标签: mysql laravel laravel-4 schema storage-engines


【解决方案1】:

既然@alexrussell 证实了我的看法,我几乎可以肯定你只能在使用Schema::create() 创建表时定义存储引擎。
但是,您始终可以使用原始 SQL 作为最后的手段:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2013-10-19
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多