activerecord - How can i remove a column from table using rails console -


it possible remove column using rails migration.

class someclass < activerecord::migration   def self.up     remove_column :table_name, :column_name   end end 

i want know if there way remove column table using console.

you can run codes in up method directly in rails console:

>> activerecord::migration.remove_column :table_name, :column_name 

if have migration file such "db/migrate/20130418125100_remove_foo.rb", can this:

>> require "db/migrate/20130418125100_remove_foo.rb" >> removefoo.up 

if want rake db:migrate, try this:

>> activerecord::migrator.migrate "db/migrate" 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -