OnlineMigrations v0.5.0 Release Notes
Release Date: 2022-06-23 // almost 2 years ago-
โ Added check for index corruption with PostgreSQL 14.0 to 14.3
๐ No need to separately remove indexes when removing a column from the small table
โ Add ability to perform specific action on a relation or individual records using background migrations
Example, assuming you have lots and lots of fraud likes:
class DeleteFraudLikes < ActiveRecord::Migration[7.0] def up perform_action_on_relation_in_background("Like", { fraud: true }, :delete_all) end end
Example, assuming you added a new column to the users and want to populate it:
class User < ApplicationRecord def generate_invite_token self.invite_token = # some complex logic end end perform_action_on_relation_in_background("User", { invite_token: nil }, :generate_invite_token)
You can use
delete_all
/destroy_all
/update_all
for the whole relation or run specific methods on individual records.โ Add ability to delete records associated with a parent object using background migrations
class Link < ActiveRecord::Base has_many :clicks end class Click < ActiveRecord::Base belongs_to :link end class DeleteSomeLinkClicks < ActiveRecord::Migration[7.0] def up some_link = ... delete_associated_records_in_background("Link", some_link.id, :clicks) end end
โ Add ability to delete orphaned records using background migrations
class User < ApplicationRecord has_many :posts end class Post < ApplicationRecord belongs_to :author, class_name: 'User' end class DeleteOrphanedPosts < ActiveRecord::Migration[7.0] def up delete_orphaned_records_in_background("Post", :author) end end