title: How to use SQLAlchemy Utils in a SQLAlchemy model
body: <p>I'm trying to create a user model that uses UUID as primary key:</p>
  
  <pre><code>from src.db import db # SQLAlchemy instance
  
  import sqlalchemy_utils
  
  import uuid
  
  
  class User(db.Model):
      __tablename__ = 'user'
  
      id = db.Column(sqlalchemy_utils.UUIDType(binary=True), primary_key=True, nullable=False)
  </code></pre>
  
  <p>But when I generate the migrations I receive: </p>
  
  <pre><code>File "/home/pc/Downloads/project/auth/venv/lib/python3.6/site-packages/alembic/runtime/environment.py", line 836, in run_migrations
      self.get_context().run_migrations(**kw)
    File "/home/pc/Downloads/project/auth/venv/lib/python3.6/site-packages/alembic/runtime/migration.py", line 330, in run_migrations
  step.migration_fn(**kw)
    File "/home/pc/Downloads/project/auth/migrations/versions/efae4166f832_.py", line 22, in upgrade
      sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(length=16), nullable=False),
  NameError: name 'sqlalchemy_utils' is not defined`
  </code></pre>
  
  <p>I had try to explicity inform the module I'm using like <a href="https://stackoverflow.com/questions/30132370/trouble-when-using-alembic-with-sqlalchemy-utils">this</a> and use a 'internal' implementation that <a href="https://docs.sqlalchemy.org/en/latest/core/custom_types.html#backend-agnostic-guid-type" rel="noreferrer">SQLAlchemy</a></p>
  
  <p>Obs: If I manualy import the <code>sqlalchemy_utils</code> in the <code>/migrations/version/efae4166f832_.py</code> and remove the length that is generated automaticaly <code>sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(length=16), nullable=False)</code> it works <a href="https://i.imgur.com/5aydtDY.png" rel="noreferrer">fine</a></p>
  
  <p>I generate the migrations using a <code>generate.py</code> script:</p>
  
  <pre><code>from src import create_app
  
  from src.db import db
  
  from flask_migrate import Migrate
  
  # Models
  
  from src.user.models.user import User
  
  app = create_app()
  
  migrate = Migrate(app, db)`
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/PQrKG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PQrKG.png" alt="enter image description here"></a></p>
  
  <p>Obs: MySQL engine</p>
  
  <p>I expect that when I generate migration it generate a user model that uses UUID implemented from SQLAlchemy Utils as primary key</p>