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?



what is a rails migration? Write up a short example of a simple rails migration with a table called ..

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

Post New Answer

More Ruby on Rails Interview Questions

Do you know the role of garbage collection in ruby on rails?

1 Answers  


What is the use of $ in ruby?

1 Answers  


What do you understand by rails?

1 Answers  


What is the purpose of load in ruby?

1 Answers  


What are the three methods to install ruby on rails?

1 Answers  


what is session and cookies

4 Answers  


Explain the various ide's of ruby on rails.

1 Answers  


What is the difference between Render vs. Redirect_to in ruby on rails ?

1 Answers  


What is unit testing (in classical terms)? What is the primary technique when writing a test ?

1 Answers  


how you can run Rails application without creating databases?

1 Answers  


Do you know what is rake in rails?

1 Answers  


What is the purpose of load, auto_load, and require_relative in ruby ?

1 Answers  


Categories