sqlalchemy postgresql enum does not create type on db migrate : <p>I develop a web-app using Flask under Python3. I have a problem with postgresql enum type on db migrate/upgrade.</p>

<p>I added a column "status" to model:</p>

<pre><code>class Banner(db.Model):
    ...
    status = db.Column(db.Enum('active', 'inactive', 'archive', name='banner_status'))
    ...
</code></pre>

<p>Generated migration by <code>python manage.py db migrate</code> is:</p>

<pre><code>from alembic import op
import sqlalchemy as sa

def upgrade():
    op.add_column('banner', sa.Column('status', sa.Enum('active', 'inactive', 'archive', name='banner_status'), nullable=True))

def downgrade():
    op.drop_column('banner', 'status')
</code></pre>

<p>And when I do <code>python manage.py db upgrade</code> I get an error:</p>

<pre><code>...
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "banner_status" does not exist
LINE 1: ALTER TABLE banner ADD COLUMN status banner_status

 [SQL: 'ALTER TABLE banner ADD COLUMN status banner_status']
</code></pre>

<p><strong>Why migration does not create a type "banner_status"?</strong></p>

<p><strong>What am I doing wrong?</strong></p>

<pre><code>$ pip freeze
alembic==0.8.6
Flask==0.10.1
Flask-Fixtures==0.3.3
Flask-Login==0.3.2
Flask-Migrate==1.8.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.1
itsdangerous==0.24
Jinja2==2.8
Mako==1.0.4
MarkupSafe==0.23
psycopg2==2.6.1
python-editor==1.0
requests==2.10.0
SQLAlchemy==1.0.13
Werkzeug==0.11.9
</code></pre>
