Dinesh Saini
Dinesh Saini

Reputation: 11

Generate Migration for adding new column using rake task in rails

How can I generate migration to add a column in my existing model using rake task in rails ?

The following migration should be generate using a rake task

class AddNameToCustomer < ActiveRecord::Mirgation
  def change
    add_column :customer, :name, :string
  end
end

Upvotes: 1

Views: 1129

Answers (1)

Rahul
Rahul

Reputation: 229

namespace :dummy do
  task test: :environment do
   `rails generate migration AddNameToCustomers name:string`
   sleep 2
   `rake db:migrate`
  end
end

Upvotes: 1

Related Questions