David Hoelzer David Hoelzer - 9 months ago 62
SQL Question

Ruby on Rails / ActiveRecord and Table Partitions

I've read the documentation and been able to find anything to assist me so far. I've also read a large number of blog articles, but nothing seems to answer my question directly:

Is it possible to manage table partitions in an InnoDB table from with ActiveRecord? I'd really prefer to keep things very clean and I'm trying to avoid writing external scripts to try to automate the creation/deletion of partitions over time.


Yes, you can! But I don't think that there is a gem that will do it for you.

In order to perform partition management you need to do the hard work by yourself and send the command that you need to run on the DB directly via the connection in the following way

ActiveRecord::Base.connection.execute("ALTER TABLE your_table drop partition p0")