ホーム>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, including affiliate links, that help fund our operations.
As an Amazon Associate, Laratech earns from qualifying purchases.

This is a solution for when an error occurred while 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.

See you!

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!