Is there some special syntax to add timestamp column to multiple tables?
Not a specific special-purpose syntax, but you can certainly iterate over an array of table names, and perform the same migration steps on each one.
class AddTimeStampsToABandC < ActiveRecord::Migration
AFFECTED_TABLES = [:table_a, :table_b, :table_c]
def self.up
AFFECTED_TABLES.each do |t|
add_timestamps(t)
end
end
def self.down
AFFECTED_TABLES.each do |t|
remove_timestamps(t)
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With