How often do you have to make a migration in RAILS?

0

In the guides and tutorials says that when you create a model, you create a migration that you then execute with rake db:migrate .

But in what other cases do you have to create a migration and execute it?

When you change the model, do you have to create it? Is it necessary to create it manually or can it be generated automatically?

    
asked by Extermis 16.01.2018 в 09:07
source

2 answers

1

Migrations are a convenient way to modify your database in a structured and organized way.

If you need to generate them when you want to add columns to a table or modify your model. It can be created manually and also automatically with

rails g migration addColumnToUsers

for example.

If you want to know more about migrations you can read these guides: - link - link

    
answered by 16.01.2018 в 17:44
0

Migrations are the changes you make to tables in the database. You should not make changes directly in the database, the ideal and correct is to make changes through migrations.

As for when to run a db: migrate, it's when you finish your migration.

It is also the case that the same rails gives you a message informing you that there is a migration pending to be deployed.

Greetings.

    
answered by 22.02.2018 в 22:41