title: Django/PostgreSQL varchar to UUID
body: <p>I'm trying to update a project from Django 1.7 to 1.9. It unfortunately used the django-extensions <code>UUIDfield</code> which used a <code>varchar</code> internally. I'm trying to change those fields to the <code>uuid</code> type in the database.</p>
  
  <p>I've already created a custom migration, told Django the migration is going to use its own SQL to do it. My problem comes when I do this (the column is named <code>guid</code>):</p>
  
  <pre><code>alter table tablename alter column guid type uuid using guid::uuid;
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>ERROR: operator class "varchar_pattern_ops" does not accept data type uuid</p>
  </blockquote>
  
  <p>I am really not that familiar with PostgreSQL and am in a bit over my head. Can I create a CAST or something to fix this? I can't figure out how I would.</p>
  
  <p>I am trying to use the <a href="http://baltaks.com/2015/08/how-to-change-text-fields-to-a-real-uuid-type-for-django-and-postgresql" rel="nofollow">script from here</a> which is supposed to take care of index dependencies but I am really in over my head.</p>