TimescaleDB extension for Rails 
timescaledb-rails extends ActiveRecord PostgreSQL adapter and provides features from TimescaleDB. It provides support for hypertables and other features added by TimescaleDB PostgreSQL extension.
Installation
Install timescaledb-rails from RubyGems:
$ gem install timescaledb-rails
Or include it in your project's Gemfile with Bundler:
gem 'timescaledb-rails', '~> 0.1'
Examples
Create a hypertable from a PostgreSQL table by doing:
class CreateEvent < ActiveRecord::Migration[7.0]
def change
create_table :events, id: false do |t|
t.string :name, null: false
t.time :occured_at, null: false
t.
end
create_hypertable :events, :created_at, chunk_time_interval: '2 days'
end
end
Create a hypertable without a PostgreSQL table by doing:
class CreatePayloadHypertable < ActiveRecord::Migration[7.0]
def change
create_hypertable :payloads, :created_at, chunk_time_interval: '5 days' do |t|
t.string :ip, null: false
t.
end
end
end
Enable hypertable compression by doing:
class AddEventCompression < ActiveRecord::Migration[7.0]
def change
add_hypertable_compression :events, 20.days, segment_by: :name, order_by: 'occured_at DESC'
end
end
Supported Ruby/Rails versions
Supported Ruby/Rails versions are listed in .github/workflows/ci.yaml
License
Released under the MIT License. See the LICENSE file for further details.
About Crunchloop

timescaledb-rails is supported with :heart: by Crunchloop. We strongly believe in giving back :rocket:. Let's work together Get in touch.