Understand migration in rails
Introduction h2>
As I was studying Ruby on Rails, I didn't understand various words and concepts related to data manipulation, so I will organize them as a memorandum.
Questions about migration h2>
While studying Rails, I had the following questions.
Part 1 What are migrations, models, and migration files in the first place?
Part 2 When do you migrate?
Part 3 What do you create a migration file for? b>
I will think about each while organizing.
Part 1 What are migrations, models, and migration files in the first place? h2>
When manipulating data with Rails, the terms "migration," "model," and "migration file" come up. If you continue studying without understanding the meaning of the terms, you will always come across the question, "What does this mean?" (Me too, I was like that)
Therefore, I decided to deepen my understanding of the terms once again.
In a word, it looks like this.
● Model
A class that manipulates data. Define for each table </ b>
● Migration
Rewrite the table design document </ b>
● Migration file
A description of how to rewrite the design document </ b>
Let's take a closer look.
● Model h3>
Rails uses a design pattern called MVC. The image looks like an image.
![rails_モデル理解.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/176783/431b7bd3-67fb-8d51-741e-98cc58cab6ab.png)
While each component has its own role, the role of the model is data and business logic. Especially used for database operations. Here is the logic for the operation. In rails, models are defined in the form of classes.
Models are created for each table, and operations such as creating and deleting tables are performed through each model. (Image like in a purple balloon)