ActiveRecord MySQL Partitions
Check out the below example of how to create partitioned MySQL tables within a Rails Migration. We’ve had a handful of tables that we continually want to partition and a team member wrote the below.Here’s the migration snippet
class AddResultsTable < ActiveRecord::Migration
def self.up
create_partitioned_table :results do |t|
The below creates a results table partitioned by day. The example migration defaults to 4 days back and 4 days forward. We then have a few scripts to manage our partitioned tables.
Here’s the rails source