Laravel Schema Builder alter storage engine
Asked Answered
C

1

6

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');
    });
}
Consolidate answered 16/12, 2014 at 8:22 Comment(2)
I'm not sure but I think you can only define it when you create the table, not change it afterwards.Ssw
Pretty sure @Ssw is correct there.Aegean
S
10

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');
Ssw answered 16/12, 2014 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.