title: Using interval in PostgreSQL with Ruby on Rails
body: <p>I want to save durations (2 days, 5 years, ...) as intervals in PostgreSQL from my Rails application.</p>
  
  <p>Both duration_min and duration_max are values like "2 days" or "5 years", so each of them is an interval by itself:</p>
  
  <pre><code>  def change
      create_table :times do |t|
        t.interval  :duration_min
        t.interval  :duration_max
        t.timestamps
      end
    end
  </code></pre>
  
  <p>but the DB migration fails when setting the data type to "interval" and rake returns:</p>
  
  <pre><code>undefined method 'interval' for #&lt;ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x007f8615694360&gt; 
  </code></pre>
  
  <p>How do I define the table for it to accept (and understand) an input like "2 days"?</p>