I am using laravel and laravel migration mechanism. I created tables and seted up foreign keys. But the tables are MyISSAM so no foreign keys are created. Where do I enable / configure this? (to change it to InnoDB and not in the mysql server).
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Like document Laravel: https://laravel.com/docs/4.2/schema#storage-engines
P/s: Thanks @Nico Haase for reminding me to provide the link.
Define engine like this
I found @ThomasLAURENT is the best solution but what about the existing tables I have in my database.
Working around.
This will allow us to convert all the tables and roll-back them when I need.
I would recommend to update your Mysql to 5.5 or higher. The default storage engine for Mysql now is InoDB
http://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html
Once done, you can easily map relationships within the entity classes via Laravel
Another approach (for whose that don't uses database.php) is to include on
.env
file:DB_ENGINE=InnoDB
Remember to check if you have
'engine' => env('DB_ENGINE', null),
on your database.phpYou can edit your /config/database.php file, search for mysql entry and change:
'engine' => null,
to
'engine' => 'InnoDB',
This saves you from adding
$table->engine = "InnoDB";
for each of your Schemas ;)