What are database model migrations?

6

Some MVC frameworks (Rails, Laravel, and others) provide migrations of the database model. What are they, how do they work and what are the advantages / disadvantages of using them?

    
asked by anonymous 19.02.2014 / 01:41

2 answers

2

Migration is the procedure that changes the state of a database.

  

As with source code, the structure of a database changes as we develop an application tied to that database. For example, throughout development, we may want to add a new table; or after a deploy routine, we noticed that you need to add a new index or column. It is important that we follow these structural changes in the database (called migrations) as we do with the source code. If the source code and the database are out of sync, it is very likely that the system as a whole will begin to have problems.

(translated from link )

In short: suppose your application was modeled for state A of a database, and after insertion of a given new resource, the database had to be changed to state B. This change occurred by which are usually a set of queries that add columns, tables, indexes, and data in the database, so that it is in the format required by the application.

    
19.02.2014 / 01:47
2
  

What are the advantages / disadvantages of using them?

Basically, you gain greater control of bank states at different times. It can also be used in conjunction with a version control system, such as Git, so that it can be easily executed by other programmers to have the current state of the database.

Making changes "on hand" via SQL, other users will not be able to reproduce the changes on their machines, unless they know exactly what has changed.

Like ORMs, Migrations also generate the correct SQL syntax depending on the database.

    
18.07.2014 / 18:09