R
R
Roman Volkov2015-03-28 15:28:56
MySQL
Roman Volkov, 2015-03-28 15:28:56

How to combine all migrations into one?

The project is being developed by several programmers and more than 20 migration files have been collected over time. Is there any way to combine all migrations into one. So that when creating a database, an actual database is immediately created, and not a basis on which migrations will be imposed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vsuhachev, 2015-03-28
@white_wolf_17

Rails has a file db/schema.rb which is:
1) updated after each migration is applied
2) it is recommended to store it under version control
3) it is used to create a database schema without migrations, see the rake task db:schema:load

I
index0h, 2015-03-28
@index0h

Migration is an iteration of changing the database, with the possibility of rollback in case of errors. Raising the issue of merging migrations into one makes sense only if this leads to unpleasant consequences, for example: raising the dev environment - it performs UP of the database for more than an hour, or in the event of a rollback, the data will be destroyed (although for such a migration, the developer needs to put a mop somewhere ), or something else. Just "many migration files" is NOT the reason.
Generally speaking, you can do the following: dump the database, and then create a separate migration that will only perform this dump.

N
Nikolai Markov, 2015-04-01
@manameiz

Strictly speaking, if you use code in migrations that is no longer in the project, you need to edit such migrations yourself (or it’s better not to create them at all).
See also https://github.com/jalkoby/squasher. Haven't tried it myself, but it seems to be what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question