departurerb / departure

Percona's pt-online-schema-change runner for ActiveRecord migrations.
Other
141 stars 53 forks source link

Fix add_index on Rails 6.1 #67

Closed sikachu closed 3 years ago

sikachu commented 3 years ago

This PR fixes the problem that add_index no longer uses pt-online-schema-change to alter the table on Rails 6.1+.

This regression was unintentionally introduced back in #58 when an update was made to make Departure works with Rails 6.1. This did not get caught by our test suite because the test suite did not really test that the command was properly shelled out to pt-online-schema-change or not, and only asserting the result of the operation.

This commit updates the code in add_index to execute query with ALTER TABLE instead of CREATE INDEX. We need to call execute with a SQL starting with ALTER TABLE for Departure to kick in and shell out to pt-online-schema-change.

This commit also update specs related to adding/removing index to making sure that we actually call pt-online-schema-change to perform the DDL operation by making sure that Open3.popen3 has been called to prevent future accidental regression.

This fixes #61.

davidmyersdev commented 3 years ago

I am running into a similar problem with remove_index, but this PR does not fix it.