Skip to content

single file api? #19

@davidbiehl

Description

@davidbiehl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions