LaravelのマイグレーションでrenameColumn()
やdropColumn()
を使うと「Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
」などというエラーが出る事があります。
# php artisan migrate
Migrating: 2020_03_16_173458_rename_local_to_user_table
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
at /var/www/vendor/laravel/framework/src/Illuminate/Database/MySqlConnection.php:65
61| * @return \Doctrine\DBAL\Driver\PDOMySql\Driver
62| */
63| protected function getDoctrineDriver()
64| {
> 65| return new DoctrineDriver;
66| }
67|
68| /**
69| * Bind values to their parameters in the given statement.
Exception trace:
1 Illuminate\Database\MySqlConnection::getDoctrineDriver()
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:892
2 Illuminate\Database\Connection::getDoctrineSchemaManager()
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:880
Please use the argument -v to see more details.
カラム名の変更やカラムの削除を行うにはdoctrine/dbal
パッケージをインストールしておく必要があります。
composerコマンドでインストールしましょう。
# composer require doctrine/dbal
これでマイグレーションがうまくいくはずです。
# php artisan migrate
Migrating: 2020_03_16_173458_rename_local_to_user_table
Migrated: 2020_03_16_173458_rename_local_to_user_table (0.81 seconds)
以上です。