procore-oss / handcuffs

A Ruby gem for running Active Record migrations in phases
MIT License
92 stars 6 forks source link

single file api? #19

Closed davidbiehl closed 8 months ago

davidbiehl commented 7 years ago

just wondering if an api that has multiple phases in a single migration file would be useful to you? using the example from the readme, it could look like:

class AddOnSaleColumn < ActiveRecord::Migration

  def up
    phase(:pre_restart) do
      add_column :products, :on_sale, :boolean
    end

    phase(:post_restart) do
      add_index :products, :on_sale, algorithm: :concurrently
    end
  end

  def down
    remove_column :products, :on_sale
  end

end

or

class AddOnSaleColumn < ActiveRecord::Migration

  phase(:pre_restart) do |migrate|
    migrate.up do
      add_column :products, :on_sale, :boolean
    end

    migrate.down do
      remove_column :products, :on_sale
    end
  end

  phase(:post_restart) do |migrate|
    migrate.up do
      add_index :products, :on_sale, algorithm: :concurrently
    end
  end

end

to my mind, this api has the best of both worlds: a developer can clearly see the entire purpose of the migration without having to look at multiple files while also preserving the desired phase order.

i'd be happy to work on it if something like this aligns with your vision.

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.