Migrations will raise an exception if there are multiple column defin… #33029
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.
Please see the contribution instructions for more information.
In Rails 6, a "bug fix" was added to avoid creating duplicate columns: rails/rails#33029 This wasn't very well described what this was fixing, but this seems to be the issue it was fixing: rails/rails#33024 However, the problem we had as a result was this error with our specs when running migrations: 1) ExpandDialogFieldDefaultValueSize#down with empty tables Failure/Error: super StandardError: An error has occurred, this and all later migrations canceled: you can't define an already defined column 'miq_server_id'. # ./db/migrate/20160328204930_remove_miq_server_product_update_join_table.rb:21:in `block in down' # ./db/migrate/20160328204930_remove_miq_server_product_update_join_table.rb:20:in `down' # ./lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:6:in `block in migrate' # ./lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:18:in `clearing_caches' # ./lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:5:in `migrate' # ./spec/support/migration_helper.rb:109:in `block in migrate_to' # ./spec/support/migration_helper.rb:99:in `suppress_migration_messages' # ./spec/support/migration_helper.rb:105:in `migrate_to' # ./spec/support/migration_helper.rb:42:in `prepare_migrate' # ./spec/support/migration_helper.rb:8:in `block (2 levels) in migration_context' # ------------------ # --- Caused by: --- # ArgumentError: # you can't define an already defined column 'miq_server_id'. # ./db/migrate/20160328204930_remove_miq_server_product_update_join_table.rb:21:in `block in down' And was expressed by this issue to rails: rails/rails#35448 In which the answer was "fix your migrations". I don't really buy that answer, as that is why they have versioned migration classes in the first place, but for now, this is the fix available to us and seems to allow most of the specs to pass. On top of that, we can't use `create_join_table` as we previously did since we now can't overwrite default columns and choose what column type we want to use since the only thing we can provide with the kwargs is the `:column_options`, but we will always get the foriegn_key columns as `integer`. That said, this is a down migration, so probably not worth investing trying to get this changed upstream.