Flask-Migrate having issue with enum class in models
<p>Using flask-migrate before I was able to create enums by using flask-sqlalchemy's db.Enum and entering the values in as strings like so.</p>

<pre><code>reservation_status = db.Enum('pending', 'confirmed, name='reservation_status_enum')
</code></pre>

<p>I decided to start using enum classes like the following. According to the <a href="http://docs.sqlalchemy.org/en/latest/core/type_basics.html?highlight=enum#sqlalchemy.types.Enum" rel="nofollow">sqlalchemy docs</a> works fine.</p>

<pre><code>class Status(enum.Enum):
    pending = 'pending'
    confirmed = 'confirmed'
    rejected = 'rejected'
    abandoned = 'abandoned'

reservation_status = db.Enum(Status, name='reservation_status_enum')

class Reservation(db.Model):
    __tablename__ = 'reservations'

    id = db.Column(db.Integer, primary_key=True)
    status = db.Column(reservation_status, default=Status.pending)
    ...
</code></pre>

<p>When I try to use the migrate command I get an invalid syntax error in the generated code as follows. The error is exactly what was written to the file.</p>

<pre><code>    sa.Column('status', sa.Enum(&lt;enum 'Status'&gt;, name='reservation_status_enum'), nullable=True),
                            ^
SyntaxError: invalid syntax
</code></pre>

<p>Thanks to user @dim, I was able to resolve the issue by upgrading just sqlalchemy to beta 1.1.0b3. As is most cases, it was user error(me).</p>

<p>All i did was </p>

<pre><code>pip uninstall sqlalchemy
pip install sqlalchemy==1.1.0b3
</code></pre>

python flask enums sqlalchemy alembic