rahrahruby
rahrahruby

Reputation: 693

rake db:migrate alter table name

I wanted to change the name of a table I creted with rake db:migrate from financialss to financials. I created a file in my migrate directory called changeme.rb that looks like this.

 class CreateFinancials < ActiveRecord::Migration
        def self.up
             rename_table :financials, :financialss
        end

        def self.down
              rename_table :financialss, :financials
        end
   end

I tried to run the following:

rake db:migrate:up changeme.rb

and got the following error:

rake aborted! Don't know how to build task 'db:migrate:changeme.rb'

All help appreciated

Upvotes: 1

Views: 1428

Answers (1)

Eduardo Fiorezi
Eduardo Fiorezi

Reputation: 570

Use the rails generator

rails g migration MigrationName

The rails do not understand when you come out of the convention. So try to use the default generator.

Upvotes: 2

Related Questions