title: Rails Migration to convert string to integer using conversion
body: <p>There is a good question <a href="https://stackoverflow.com/questions/3537064/rails-migration-to-convert-string-to-integer">here</a> I want to elaborate on. I am trying to convert a column in my database form a string to an integer.</p>
  
  <p>I thought the conversion would be pretty straight forwrad. Currently my strings are </p>
  
  <pre><code>["10", "12", "125", "135", "140", ...]
  </code></pre>
  
  <p>My migration file includes:</p>
  
  <pre><code>def change
      change_column :table_name, :product_code, :integer
  end
  </code></pre>
  
  <p>Rails tries this but Postgresql thows back an error.</p>
  
  <blockquote>
    <p>PG::Error: ERROR:  column "product_code" cannot be cast automatically to type integer<br>
    HINT:  Specify a USING expression to perform the conversion.</p>
  </blockquote>
  
  <p>I am not sure how I use this 'USING' expression in my rails migration.</p>
  
  <p>So I thought the conversion would be pretty straight forward. What should I use as the USING expression?</p>