Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Better usage when use make_required make_optional and remove on the migration. #1033

Open
zw963 opened this issue Apr 27, 2024 · 0 comments
Labels
clarify api Rename/remove/add something to make the API easier to understand

Comments

@zw963
Copy link
Contributor

zw963 commented Apr 27, 2024

Assume my db table foo, have two column, column1, column2

this is a common use case where the data from column1 is migrated to column2 and then remove column column1, and then make column2 required.

so, migration like this:

class Foo::V20240427102500 < Avram::Migrator::Migration::V1
  def migrate
      # Do data migrating from column1 to column2 ...

    make_required table_for(Foo), :column2
    alter table_for(Foo) do
      remove :column1
    end
  end

  def rollback
  end
end

It works!, but i consider it is better if we can use like following:

 alert table_for(Foo) do
   make_required :column2
   remove :column1
 end

Or

make_required table_for(Foo), :column2
remove table_for(Foo), :column1

Thanks


EDIT: okay, probably write migrate data and delete old column in same migration file is not good idea, but anyway, same usage is better.

@jwoertink jwoertink added the clarify api Rename/remove/add something to make the API easier to understand label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarify api Rename/remove/add something to make the API easier to understand
Projects
None yet
Development

No branches or pull requests

2 participants