Cleaning up deprecated warnings during a database migration

Don't ignore it

Joel Clermont
Joel Clermont

When you're moving from one database server to another, you often will create a dump of the database and import it into the new server.

While importing a MySQL dump, I always recommend to pass the --show-warnings flag to see if there are any deprecated features used in the dump.

On a recent migration, I saw a lot of deprecated warnings like this:

Warning (Code 1681) Integer display width is deprecated and will be removed in a future release

In the past I wrote explained what int "lengths" mean, and how pointless they are.

A migration is a perfect time to clean up these warnings and remove this deprecated syntax.

First, I'd recommend dumping schema and data separately. The schema file is small and easy to edit, but your data file could be many gigabytes and will choke most text editors.

Pass --no-data to mysqldump to only dump the schema. And then for your second file, you can pass --no-create-info to only dump the data.

Now you have a small schema file to edit, and you can search for all the instances of INT(X) and replace with INT to eliminate the deprecated display width before importing it on your new database server.

Hope this helps,


P.S. I'm a huge fan of keeping your application and data tidy. Want some of that attention to detail for your project?

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.