change column name rails code example
Example 1: how to I change the name of a column in rails
$ rails g migration rename_season_to_season_id
class RenameSeasonToSeasonId < ActiveRecord::Migration
def change
rename_column :shoes, :season, :season_id
end
end
Example 2: laravel migration change column name
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('from', 'to');
});
Example 3: active record modify column name
rename_column :table, :old_column, :new_column
Example 4: change column rails example
def change
change_column(:table_name, :column_name, :new_type)
end
Example 5: rename column in db rails
rails generate migration rename_title_to_name_in_tasks