Why do we need database migrations?

Giuseppe Crinò
1 min readFeb 17, 2021

I knew keeping migrations is something you wanna do when managing databases. But I’ve always had an hard time justifying their importance with other fellow engineers.

Even I wasn’t 100% sure on why they’re valuable.

Answer: You need migrations as soon as you have more than one database instance.

This happens really fast as you always have at least prod and your local dev environment. You can’t dump the whole prod db and load it on your laptop. Instead, you need to create the tables from scratch and load data into those tables.

If the database and the application were written in stone you could setup a create_tables.sql andinsert_data.sql scripts.

But they’re not. They keep on changing because you’ll need new feature or find bugs.

The realistic alternative is to write a series of SQL scripts to execute in order. And you’ve just invented migrations.

--

--