ホーム > Laravel > When I tried to change a column in Laravel's migration, an error occurred
Laravel

When I tried to change a column in Laravel's migration, an error occurred

Thank you for your continued support.
This article contains advertisements that help fund our operations.

⇨ Click here for the index of Laravel articles

I wrote about what to do when an error occurred when trying to change a column in Laravel's migration.

Environment

Laravel6

[Related article] How to create a database with Laravel (migration)

Modifying the migration file

When changing a column in Laravel,

① Install doctrine/dbal

② Add the following description to the migration file

$table->string('content',1000)->change()

and execute.

Error message

When I ran the command

php artisan migrate

I got the following error:

Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".

Solution

The error occurred because the doctrine/dbal package version did not match.

It seems that Laravel6 requires the previous version of doctrine/dbal.

So,

Conclusion

composer require "doctrine/dbal:^2.6"

This command will solve the issue!

Example that will cause problems by installing the latest version:

composer require doctrine/dbal

Summary

That's all.

For any feedback or complaints, please contact me via Twitter DM.

See you!

Popular articles

Deploying a PHP7.4 + Laravel6 project to AWS EC2

Implementing breadcrumbs in Laravel with laravel-breadcrumbs

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!