This episode covers different tips and tricks around database migration files. https://www.driftingruby.com/episodes/activerecord-migrations
2 Likes
Thanks.
A good new option to be used in migration for adding index to avoid locking is:
class AddMigrationForPerformanceExample < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
def change
add_index(
:table,
[
:col_1,
:col_2,
],
# Prevent locking thus downtime
# Requires `disable_ddl_transaction!`
# https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in
algorithm: :concurrently,
)
end
end
2 Likes