what is a rails migration? Write up a short example of a simple rails migration with a table called customers, a string column called name, and a text column called description?
Answer / Shailja Singh
Rail Migration in Ruby on Rails is a way to manage database schema changes. A migration file defines the structure of a database table, including its columns and their data types. Here's an example of a simple Rails migration:nn```rubynrails generate migration CreateCustomers name:string description:textn```nThis command creates a new migration file called `create_customers.rb` in the `db/migrate` directory.nn```rubynclass CreateCustomers < ActiveRecord::Migration[6.1]
def change
create_table :customers do |t|
t.string :name
t.text :description
t.timestamps
end
endn```nThis migration defines a `Customers` table with two columns: `name` and `description`. The `t.timestamps` command adds created_at and updated_at timestamps by default.
| Is This Answer Correct ? | 0 Yes | 0 No |
Do you know the role of garbage collection in ruby on rails?
What is the use of $ in ruby?
What do you understand by rails?
What is the purpose of load in ruby?
What are the three methods to install ruby on rails?
what is session and cookies
Explain the various ide's of ruby on rails.
What is the difference between Render vs. Redirect_to in ruby on rails ?
What is unit testing (in classical terms)? What is the primary technique when writing a test ?
how you can run Rails application without creating databases?
Do you know what is rake in rails?
What is the purpose of load, auto_load, and require_relative in ruby ?