Sha256: b52af1ffbfdbd3521df0ab9150dc611c20a8840c58f5ac229c94b1981f78d9d4

Contents?: true

Size: 574 Bytes

Versions: 4

Compression:

Stored size: 574 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "timescale"

def uri_from_test
  require 'dotenv'
  Dotenv.load!
  ENV['PG_URI_TEST']
end

ActiveRecord::Base.establish_connection(ARGV[0] || uri_from_test)

Timescale::Hypertable.find_each do |hypertable|
  class_name = hypertable.hypertable_name.singularize.camelize

  model = Class.new(ActiveRecord::Base) do
    self.table_name = hypertable.hypertable_name
    self.primary_key = self.column_names.first

    acts_as_hypertable
  end

  Timescale.const_set(class_name, model)
end

require "pry"
Pry.start(Timescale)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timescaledb-0.1.5 bin/console
timescaledb-0.1.4 bin/console
timescaledb-0.1.3 bin/console
timescaledb-0.1.2 bin/console