Skip to content

Releases: moskvin/safe_migrations

v1.0.0

24 Oct 01:48

Choose a tag to compare

SafeMigrations v1.0.0 - 2025-10-24

G'day, mate! Welcome to the first ripper release of SafeMigrations, a gem that makes your Rails migrations as safe as a kangaroo in the outback. This initial release brings idempotent safe_ prefixed methods to prevent migration errors, with automatic reversal via Rails' CommandRecorder for change-based migrations.

Added

  • Idempotent Migration Helpers: Introduced safe_create_table, safe_add_column, safe_add_index, safe_remove_column, safe_rename_column, safe_add_foreign_change_column, safe_change_column_null, and more, which skip execution if schema elements already exist.
  • CommandRecorder Integration: Extended Rails' CommandRecorder to auto-reverse safe_ methods (e.g., safe_create_table → safe_drop_table) in change method rollbacks.

Notes

  • Rails Compatibility: Built for Rails 7.2+ and Ruby 3.2.
  • Warning: Due to CommandRecorder, rollbacks may affect pre-existing schema elements (e.g., dropping tables not created by the migration). Use reversible blocks for critical cases.
  • Usage Example:
class CreateUsers < ActiveRecord::Migration[7.2]
  def change
    safe_create_table(:users) do |t|
      t.string :name
    end
    safe_add_column(:users, :email, :string)
  end
end

Contributing

Keen to make SafeMigrations even better? Chuck us a pull request or bug report at https://github.com/moskvin/safe_migrations.

Crack on and make your migrations safe as, mate!