Answers for "change column name rails"

PHP
3

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
Posted by: Guest on February-14-2020
12

laravel migration change column name

Schema::table('users', function (Blueprint $table) {
    $table->renameColumn('from', 'to');
});
Posted by: Guest on April-24-2020
2

rename column in db rails

rails generate migration rename_title_to_name_in_tasks
Posted by: Guest on December-17-2020
1

rename column in db rails

class RenameTitleToNameInTasks < ActiveRecord::Migration[6.0]
  def up
    rename_column :tasks, :title, :name
  end

  def down
    rename_column :tasks, :name, :title
  end
end
Posted by: Guest on December-17-2020

Code answers related to "change column name rails"

Browse Popular Code Answers by Language