lib/timescaledb/migration_helpers.rb in timescaledb-0.2.9 vs lib/timescaledb/migration_helpers.rb in timescaledb-0.3.0
- old
+ new
@@ -47,11 +47,11 @@
**hypertable_options)
original_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = Logger.new(STDOUT)
- options = ["chunk_time_interval => INTERVAL '#{chunk_time_interval}'"]
+ options = ["chunk_time_interval => #{chunk_time_interval_clause(chunk_time_interval)}"]
options += hypertable_options.map { |k, v| "#{k} => #{quote(v)}" }
arguments = [
quote(table_name),
quote(time_column),
@@ -162,9 +162,17 @@
def build_with_clause_option_string(option_key, options)
return '' unless options.key?(option_key)
value = options[option_key] ? 'true' : 'false'
",timescaledb.#{option_key}=#{value}"
+ end
+
+ def chunk_time_interval_clause(chunk_time_interval)
+ if chunk_time_interval.is_a?(Numeric)
+ chunk_time_interval
+ else
+ "INTERVAL '#{chunk_time_interval}'"
+ end
end
end
end
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(Timescaledb::MigrationHelpers)