Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downgrade don't drop ENUM Column Types #48

Closed
ibrahim12 opened this issue Mar 5, 2015 · 4 comments
Closed

Downgrade don't drop ENUM Column Types #48

ibrahim12 opened this issue Mar 5, 2015 · 4 comments
Labels

Comments

@ibrahim12
Copy link

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)
@miguelgrinberg
Copy link
Owner

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.

@ibrahim12
Copy link
Author

@miguelgrinberg Is Flask-Migrate using the latest 0.7.5 version of Alembic ?

@miguelgrinberg
Copy link
Owner

Flask-Migrate works with any version of Alembic from 0.6 and up.

@MrEbbinghaus
Copy link

If anyone comes here from Google.
This is the Issue you are looking for: sqlalchemy/alembic#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants