Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 735
David Hoelzer Avatar asked Apr 11 '26 18:04

David Hoelzer


1 Answers

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")
like image 145
Tata Avatar answered Apr 14 '26 07:04

Tata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!