-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add rename and rename_belongs_to for migrations. #366
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it 👍
Could you add that a migration that uses these two new methods? This will test that they work when actually used with Postgres since the spec suite runs all migrations.
Good you asked for the migration. As it turns out, you can only do one I chose to execute alter table_for(User) do
rename :name, :first_name
add name : String
end In other words, you can rename an existing column, and add a new one with the original name of the existing column, all in one migration. So, that's why I moved Although not the same issue, I also included the conversion of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@@ -166,13 +168,36 @@ class Avram::Migrator::AlterTableStatement | |||
] | |||
end | |||
|
|||
def remove(name : Symbol) | |||
dropped_rows << " DROP #{name.to_s}" | |||
{% symbol_expected_message = "%s expected a symbol like ':user', instead got: '%s'" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really cool idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was really happy with that one. 😊
A proposal as suggested in #365. This makes me think about picking up #321 as well, since the same is true.