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

Extract #build_change_column_definition #45684

Conversation

adrianna-chang-shopify
Copy link
Contributor

Summary

Define APIs on the MySQL and PostgreSQL connection adapters for building
ChangeColumnDefinition objects. These provide information on what a
column change would look like, when called with the same arguments as
would be passed to #change_column.

See #45625 for more context on exposing schema definition APIs.

Other Information

I've left out a definition for SQLite3, because it performs #change_column by replacing the entire table definition:

def change_column(table_name, column_name, type, **options) # :nodoc:
alter_table(table_name) do |definition|
definition[column_name].instance_eval do
self.type = aliased_types(type.to_s, type)
self.options.merge!(options)
end
end
end

We could define #build_change_column_definition to essentially wrap the new column definition, but this wouldn't actually be used by #change_column, and we wouldn't be able to set the ddl, so I opted to just ignore it.

Define APIs on the MySQL and PostgreSQL connection adapters for building
ChangeColumnDefinition objects. These provide information on what a
column change would look like, when called with the same arguments as
would be passed to #change_column.
@eileencodes eileencodes merged commit 214cd77 into rails:main Jul 29, 2022
@adrianna-chang-shopify adrianna-chang-shopify deleted the ac-build-change-column-definition branch August 5, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants