title: Postgres: How to convert column type from string to integer with default value?
body: <p>New to postgres. </p>
  
  <p>I have a column called "customer_id" in Postgres currently defined as "character varying". </p>
  
  <p>Looking in the DB, a lot of the rows have NULL. </p>
  
  <p>I need this column to be an INTEGER with possible NULL value.<br>
  How can I do that in postgres? </p>
  
  <p>I tried running query : </p>
  
  <pre><code> alter table leads alter column customer_id type INTEGER using CAST("customer_id" as INTEGER);
  </code></pre>
  
  <p>But I get an error saying: </p>
  
  <pre><code> default for column "customer_id" cannot be cast automatically to type integer
  </code></pre>