Max Gabderakhmanov
Max Gabderakhmanov

Reputation: 922

How to change migration file name? (Rails)

I've got an error with the migration file name (it have to be projects instead products). I've called this: 20170131095212_add_title_to_products.rb but it contains the correct table inside:

class AddReferenceToProducts < ActiveRecord::Migration
    def change
        add_column :projects, :title, :string, length: 512
    end
end

How I can change the migration file name correctly? Ruby '2.3.0', Rails '4.2.6'. Thanks.

Upvotes: 1

Views: 3035

Answers (1)

Rename filename,

20170131095212_add_title_to_projects.rb

rename class.

AddReferenceToProjects

Also you can delete migration and create new.

Upvotes: 5

Related Questions