diff --git a/docs/migrations.md b/docs/migrations.md index ac9c818..72d0c71 100644 --- a/docs/migrations.md +++ b/docs/migrations.md @@ -25,6 +25,18 @@ end This example shows a ticks table grouping ticks as OHLCV histograms for every minute. +First make sure you have the model with the `acts_as_hypertable` method to be +able to extract the query from it. + +```ruby +class Tick < ActiveRecord::Base + self.table_name = 'ticks' + acts_as_hypertable +end +``` + +Then, inside your migration: + ```ruby hypertable_options = { time_column: 'created_at', @@ -39,11 +51,6 @@ create_table :ticks, hypertable: hypertable_options, id: false do |t| t.integer :volume t.timestamps end -Tick = Class.new(ActiveRecord::Base) do - self.table_name = 'ticks' - self.primary_key = 'symbol' - acts_as_hypertable -end query = Tick.select(<<~QUERY) time_bucket('1m', created_at) as time, @@ -79,7 +86,7 @@ function that can be reusing candlesticks from smaller timeframes. `disable_ddl_transaction!` in your migration file. ```ruby - class CreateTicks < ActiveRecord::Migration[6.0] + class CreateCaggsWithData < ActiveRecord::Migration[7.0] disable_ddl_transaction! def change