A migration file is a file that describes the changes you make to the database.
#Modeling $rails g model model name #Migration file creation command $rails g migration class name
The migration file is created when the model is created. It is also possible to specify the class name and create the migration file alone. It should be easy to understand that the class name is created by "action + table name"! This will create a file called /db/migrate/timestamp_classname.rb. Here are the changes to the schema!
$rails g model model name column name: data type
Specify the content to be described in the migration file when creating the model in "Column name: Data type".
The data types that can be specified are as follows.
#Executing the migration file $ rails db:migrate
When this command is executed, the contents of the migration file will be reflected in the DB.
#Roll back the migration file $ rails db:rollback
Roll back the executed migration file.
#Check the executed migration file $ rake db:migrate:status
You can check the contents of the migration file executed by this command.