Is there any better way to add new columns to rails table than this way
class AddColumnsToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :contact1, :integer
add_column :users, :contact2, :integer
add_column :users, :contact3, :decimal
add_column :users, :contact4, :integer
add_column :users, :contact5, :integer
add_column :users, :contact6, :string
add_column :users, :contact7, :integer
add_column :users, :contact8, :integer
add_column :users, :contact9, :integer
end
end
Can we use change_table method and write these inside a block? instead of repeating the add_column again and again
Aucun commentaire:
Enregistrer un commentaire