I need to make a migration where a column is added to three separate tables. The views column is an integer and needs to also default => 0. How can I add these columns with activerecord commands? I am using postgreSQL database.
Here is how my migration should look like:
class AddViewsToRestaurantsMenusDishes < ActiveRecord::Migration[6.0]
def change
add_column Restaurant, :views, :integer, :default => 0
add_column Menu, :views, :integer, :default => 0
add_column Dish, :views, :integer, :default => 0
end
end
add_column :restaurants, :views, :integer, default: 0? Repeat two times, changing:restaurantsto:menusand:dishes?