OnlineMigrations v0.2.0 Release Notes

Release Date: 2022-01-31 // over 2 years ago
    • Check removing a table with multiple foreign keys

    • Check for mismatched reference column types

      For example, it detects cases like:

      class AddUserIdToProjects < ActiveRecord::Migration[7.0]
        def change
          add_column :projects, :user_id, :integer
        end
      end
      

      where users.id is of type bigint.

    • Add support for multiple databases to start_after and target_version configuration options

      OnlineMigrations.configure do |config|
        config.start_after = { primary: 20211112000000, animals: 20220101000000 }
        config.target_version = { primary: 10, animals: 14.1 }
      end
      
    • Do not suggest ignored_columns when removing columns for Active Record 4.2 (ignored_columns was introduced in 5.0)

    • Check replacing indexes

      For example, you have an index on projects.creator_id. But decide, it is better to have a multicolumn index on [creator_id, created_at]:

      class AddIndexOnCreationToProjects < ActiveRecord::Migration[7.0]
        disable_ddl_transaction!
      
        def change
          remove_index :projects, :creator_id, algorithm: :concurrently # (1)
          add_index :projects, [:creator_id, :created_at], algorithm: :concurrently # (2)
        end
      end
      

      If there is no existing indexes covering creator_id, removing an old index (1) before replacing it with the new one (2) might result in slow queries while building the new index. A safer approach is to swap removing the old and creation of the new index operations.