简体   繁体   中英

How to change model and update database, make migrations, in flask-admin?

I already have my flask-admin app with its models and database and tables created..

Now I would like to add a field to model and that should be reflected in the database by a new column in the model's corresponding table.

With django one would create then apply migrations..

How do I make migrations/schema-changes in flask-admin?

I would recommend checking out the section on SQLAlchemy-based database migrations in Miguel Grinberg's Database Flask Mega-Tutorial. He uses low-level SQLAlchemy APIs to put the database under version control and automate the process of database version upgrades or downgrades.

Alternatively, I recommend using Miguel Grinberg's Flask-Migrate extension which implements the functionality he describes in the aforementioned tutorial. Using this extension, you simply add an instance of the Migrate object to your application, then perform database migrations using a command line interface provided by the extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM