Creating Migration File Via Generating Rails Migration.
The general form is `rails g migration` and then you can create `books` table and state columns names and its datatypes as:
railsgmigrationCreateBooktitle:stringbrief:text
This will create migration file in `db/migrate` folder to create `books` table.
Note, The generated file doesn't create `timestamps` fields `created_at` and `updated_at` so, you can add:
t.timestampsnull: false
Also, You can edit this file and add or remove columns before making `rake db:migrate`
And, You can state all table's columns manually in the migration file not in `rails g migration` command line.
Then, Apply changes to database using:
rakedb:migrate
Now, You must create `book.rb` model manually in `app/models` to deal with `books` table as:
classBook<ActiveRecord::Baseend
Note that you can undo this migration using:
rakedb:rollback
Note, Any `rake db:rollback` may delete stored data in the `targeted` columns and can't be restored again.
Also, You can delete the migration file generated by converting `g`(for generate) to `d` (for destroy) in migration command as: