Sha256: 3b70f108a2e2a58768c602ea29155a11d917bfcf7c458349f493bd0218c6631a

Contents?: true

Size: 659 Bytes

Versions: 2

Compression:

Stored size: 659 Bytes

Contents

module Timescale
  class Chunk < ActiveRecord::Base
    self.table_name = "timescaledb_information.chunks"
    self.primary_key = "chunk_name"

    belongs_to :hypertable, foreign_key: :hypertable_name

    scope :compressed, -> { where(is_compressed: true) }
    scope :uncompressed, -> { where(is_compressed: false) }

    def compress!
      execute("SELECT compress_chunk(#{chunk_relation})")
    end

    def decompress!
      execute("SELECT decompress_chunk(#{chunk_relation})")
    end

    def chunk_relation
      "('#{chunk_schema}.#{chunk_name}')::regclass"
    end

    def execute(sql)
      self.class.connection.execute(sql)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timescaledb-0.1.2 lib/timescale/chunk.rb
timescaledb-0.1.0 lib/timescale/chunk.rb