Skip to content

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.
@adrianna-chang-shopify adrianna-chang-shopify force-pushed the ac-build-change-column-definition branch from f479582 to c59cbb5 Compare July 28, 2022 20:15
@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.

2 participants