Using rename with alter in Ecto.Migrations

178 views
Skip to first unread message

Sean Callan

unread,
Mar 19, 2016, 9:45:03 PM3/19/16
to elixir-lang-talk
Is it possible to use `rename/2` with `alter` in Ecto.Migrations?  Right now I have something like this:

def change do
  alter table(:user) do
    remove :last_name
  end

  rename table(:user), :first_name, to: :name
end

But it seems like I should be able to use `rename/2` much like `add/3` and `remove/1`:

def change do
  alter table(:user) do
    remove :last_name
    rename :first_name, to: :name
  end
end

Am I missing something?

Thanks,
Sean

José Valim

unread,
Mar 20, 2016, 3:28:07 AM3/20/16
to elixir-l...@googlegroups.com
I can't remember right now, but if you look in the issues tracker when rename was implemented, we had very good reasons to leave it outside of the alter block. I believe some SQL databases have their own statement for RENAME which are not part of alter table.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/3357fa0f-ee1e-4847-87d4-829ebbb0e21f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Callan

unread,
Mar 20, 2016, 12:09:48 PM3/20/16
to elixir-lang-talk, jose....@plataformatec.com.br
I see when it was originally created and when it was updated to be chain-able but there is no discussion.   I'm going through the issues and so far I haven't seen anything like you mentioned.

Thanks José
Reply all
Reply to author
Forward
0 new messages