A couple of models have a
belongs_to association to another model with a huge table. We need to remove the foreign key constraints from MySQL, due a technical limitation of MySQL & schema migrations.
What’s the best way to remove those MySQL foreign keys, generated for the Active Record associations, without affecting existing code that depends on the associations?
Can I just drop the constraints from MySQL and keep the code as is?
MySQL limitations context: The reason is that our MySQL database uses asynchronous replication, and the table we want to migrate is large enough that performing schema migrations with ALTER on it stalls MySQL replication. So we’re using a tool called pt-online-schema-change to perform migrations without stalling replication. However, this tool can only perform “seamless” migrations if there are no foreign keys referring to the table being modified.