Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benefits of using Migrations [duplicate]

I'm currently learning a framework that supports Migrations.

My question is: what is the main benefit for using migrations?

Why don't we just use a database adminstration tool to add/drop/alter tables and to do other operations directly? Or why not to just export my .sql file and my team import it in their databases?

like image 257
Khalid Khalil Avatar asked Feb 10 '13 11:02

Khalid Khalil


People also ask

What is an advantage of supporting migrations of existing tables?

Migrations are helpful because they allow database schemas to evolve as requirements change. They help developers plan, validate, and safely apply schema changes to their environments.

How can I improve my DMS performance?

Load multiple tables in parallel. By default AWS DMS loads eight tables at a time. You will see performance improvement by increasing the "Max Full Load Sub Tasks" parameter. Again it depends on the size of your replication instance and too many parallel threads running will reduce the performance.

What is the purpose of database migrations?

Database migration is the process of migrating data from one or more source databases to one or more target databases by using a database migration service. When a migration is finished, the dataset in the source databases resides fully, though possibly restructured, in the target databases.

Can I replicate data from encrypted data sources?

Can I replicate data from encrypted data sources? Yes, AWS Database Migration Service can read and write from and to encrypted databases.


2 Answers

Migrations are part of the deployment process. So the benefits of migrations (in general) are

  • You don't have to do it manually (because on deployment you probably forget a schema-change sooner or later)
  • You can test it locally (because you probably make mistakes sooner or later)
  • You don't have to tell your team members to change their local database manually (because thats simply annoying), or import a new dump (again ...)
  • If you have multiple environments (stage, prod, test) you have to do this step on any system. This increases the probability of mistakes
  • You probably don't want to import the (probably outdated) development-database into the live-system ;)

Note, that in the beginning of a project a schema may be simple and the database small, but this will not stay this. Sooner or later (;)) you will face huge databases, that takes time to import.

Additional: A good migration usually has a "downgrade"-step in case of errors. With your approach if the deployment goes wrong you have to revert your database changes manually, which is even more error prone.

like image 140
KingCrunch Avatar answered Sep 18 '22 02:09

KingCrunch


Think of them as version control for your database. It also makes deploying your changes to multiple environments (e.g. Your development environment, then your testing/production server) easy and automatable, rather than having to remember what you did in PHPMyAdmin.

It's easier to tell someone they need to migrate their DB than to have to tell them each individual change they need to make to their DB.

like image 43
ChrisC Avatar answered Sep 18 '22 02:09

ChrisC