Module: Timescaledb::Rails::ActiveRecord::SchemaDumper
- Defined in:
- lib/timescaledb/rails/extensions/active_record/schema_dumper.rb
Overview
:nodoc:
Instance Method Summary collapse
- #continuous_aggregate(continuous_aggregate, stream) ⇒ Object
- #continuous_aggregate_policy(continuous_aggregate, stream) ⇒ Object
- #continuous_aggregates(stream) ⇒ Object
- #table(table, stream) ⇒ Object
- #tables(stream) ⇒ Object
Instance Method Details
#continuous_aggregate(continuous_aggregate, stream) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/timescaledb/rails/extensions/active_record/schema_dumper.rb', line 28 def continuous_aggregate(continuous_aggregate, stream) stream.puts " create_continuous_aggregate #{continuous_aggregate.view_name.inspect}, <<-SQL" stream.puts " #{continuous_aggregate.view_definition.strip.indent(2)}" stream.puts ' SQL' stream.puts end |
#continuous_aggregate_policy(continuous_aggregate, stream) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/timescaledb/rails/extensions/active_record/schema_dumper.rb', line 35 def continuous_aggregate_policy(continuous_aggregate, stream) return unless continuous_aggregate.refresh? = [ continuous_aggregate.view_name.inspect, continuous_aggregate.refresh_start_offset.inspect, continuous_aggregate.refresh_end_offset.inspect, continuous_aggregate.refresh_schedule_interval.inspect ] stream.puts " add_continuous_aggregate_policy #{.join(', ')}" stream.puts end |
#continuous_aggregates(stream) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/timescaledb/rails/extensions/active_record/schema_dumper.rb', line 19 def continuous_aggregates(stream) return unless timescale_enabled? Timescaledb::Rails::ContinuousAggregate.all.each do |continuous_aggregate| continuous_aggregate(continuous_aggregate, stream) continuous_aggregate_policy(continuous_aggregate, stream) end end |
#table(table, stream) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/timescaledb/rails/extensions/active_record/schema_dumper.rb', line 50 def table(table, stream) super(table, stream) return unless timescale_enabled? return if (hypertable = Timescaledb::Rails::Hypertable.find_by(hypertable_name: table)).nil? hypertable(hypertable, stream) hypertable_compression(hypertable, stream) hypertable_reorder(hypertable, stream) hypertable_retention(hypertable, stream) end |
#tables(stream) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/timescaledb/rails/extensions/active_record/schema_dumper.rb', line 12 def tables(stream) super continuous_aggregates(stream) stream end |