0

I have a database that my laravel applications connects to, that has MyISAM tables.

So it doesn't show foreign keys, although they are implemented.

I created this migration to fix the issue and then I altered the line 'engine' => 'InnoDB', in database.php config for this connection; but I can't see that foreign keys are fixed in the designer (phpmyadmin)

$tables = [
    'categories',
    'currencies',
    ...
];
foreach ($tables as $table) {
    DB::statement('ALTER TABLE ' . $table . ' ENGINE = InnoDB');
}

How can I fix that?

3
  • I created a migration that re-creates all foreign keys, but was hopping for the code above to fix the issue. I did the code above once and worked fine, Idk wht this time it didn't Commented May 14, 2024 at 11:24
  • 1
    ISAM doesn't support foreign keys, changing the engine won't magically make keys appear where they were not before. Commented May 14, 2024 at 15:36
  • MyISAM accepted FOREIGN KEY declarations but ignored them. See this for my notes on conversion from MyISAM: mysql.rjweb.org/doc.php/myisam2innodb Commented May 14, 2024 at 18:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.