Note that there are some explanatory texts on larger screens.

plurals
  1. POAlembic: How to migrate custom type in a model?
    primarykey
    data
    text
    <p>My <code>User</code> model is</p> <pre><code>class User(UserMixin, db.Model): __tablename__ = 'users' # noinspection PyShadowingBuiltins uuid = Column('uuid', GUID(), default=uuid.uuid4, primary_key=True, unique=True) email = Column('email', String, nullable=False, unique=True) _password = Column('password', String, nullable=False) created_on = Column('created_on', sa.types.DateTime(timezone=True), default=datetime.utcnow()) last_login = Column('last_login', sa.types.DateTime(timezone=True), onupdate=datetime.utcnow()) </code></pre> <p>where <code>GUID</code> is a custom type as described in <a href="http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#backend-agnostic-guid-type" rel="noreferrer">sqlalchemy docs</a> (Exactly same)</p> <p>Now when I run</p> <pre><code>alembic revision --autogenerate -m "Added initial table" </code></pre> <p>I get my <code>upgrade()</code> as</p> <pre><code>def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('uuid', sa.GUID(), nullable=False), sa.Column('email', sa.String(), nullable=False), sa.Column('password', sa.String(), nullable=False), sa.Column('created_on', sa.DateTime(timezone=True), nullable=True), sa.Column('last_login', sa.DateTime(timezone=True), nullable=True), sa.PrimaryKeyConstraint('uuid'), sa.UniqueConstraint('email'), sa.UniqueConstraint('uuid') ) ### end Alembic commands ### </code></pre> <p>but during applying upgrade -> <code>alembic upgrade head</code>, I see </p> <pre><code>File "alembic/versions/49cc74d0da9d_added_initial_table.py", line 20, in upgrade sa.Column('uuid', sa.GUID(), nullable=False), AttributeError: 'module' object has no attribute 'GUID' </code></pre> <p>How can I make it work with <code>GUID</code>/custom type here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload