Why Flask-migrate cannot upgrade when drop column

前端 未结 3 1699
别那么骄傲
别那么骄傲 2020-12-23 10:03

I am using SqlAlchemy and Flask-migrate for DB migration. I have successfully init the DB and upgrade once, but when I deleted one of my table colu

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 10:18

    I do not know have you solved the problem. But I find a very concise solution: you can add this to the bottom of your init.py file. Afterwards, delete and rebuild your migrations:

    with app.app_context():
        if db.engine.url.drivername == 'sqlite':
            migrate.init_app(app, db, render_as_batch=True)
        else:
            migrate.init_app(app, db)
    

    hope to help you.

提交回复
热议问题