Migration script don't contains the statements for custom type drops.
if we have a table with an ENUM field say,
class A {
...
col = db.Column( db.Enum('a','b','c', name='custom_type'), default='a'),
...
}
Current Migration Script has been generated as follows,
def upgrade():
op.create_table('A',
...
sa.Column('type', sa.Enum('a', 'b','c', name='custom_type'), nullable=True),
...
)
def downgrade():
op.drop_table('A')
It don't drop the custom enum type generated, so If we downgrade once next time when we upgrade it breaks as
sqlalchemy.exc.ProgrammingError: (ProgrammingError) type "custom_types" already exists
Migration script should add the 'custom type' drop statement like below,
sa.Enum(name='custom_types').drop(op.get_bind(), checkfirst=False)
Flask-Migrate's migrations are generated by Alembic. You need to write a bug for Alembic at https://bitbucket.org/zzzeek/alembic/issues?status=new&status=open.
@miguelgrinberg Is Flask-Migrate using the latest 0.7.5 version of Alembic ?
Flask-Migrate works with any version of Alembic from 0.6 and up.
If anyone comes here from Google.
This is the Issue you are looking for: https://github.com/sqlalchemy/alembic/issues/89
Most helpful comment
If anyone comes here from Google.
This is the Issue you are looking for: https://github.com/sqlalchemy/alembic/issues/89