I would like to rename a table column from the rails console without a migration entry.
How can i do this?
rails dbconsole ALTER TABLE name RENAME column TO column
I decided to run this from the console:
ActiveRecord::Base.connection.rename_column :tablename, :old_column_name, :new_column_name
rails g migration ChangeColName
you edit the file db / migrate / "timestamp" _change_col_name.rb paste in def change -
rename_column :tablename, :old_column_name, :new_column_name -save
you start the console: rake db:migrate
rake db:migrate
Source: https://habr.com/ru/post/1202239/More articles:to determine the difference between two lists - javaHow to stop affecting CSS of other content on our site? - javaDifference between class library and ASP.NETvNext class library? - c #What is the point of dividing a project into two separate projects? - javaKarma - incorrect ui div properties during unit testing Angular JS directive - angularjsAutocomplete Makefile variable in bash - variablesrails jquery.turbolinks javascript does not work after changing a page - jquerydamaged unsorted chunks when calling free () - cHaversin vector formula with pandas framework - pythonWildFly 8.1: Server is not connected. Deployment not available - intellij-ideaAll Articles