So let's set up a virtual environment and get the basics in place.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkvirtualenv evo; | |
cdvirtualenv | |
# this installs flask, flask-script and everything you need | |
pip install Flask-Evolution | |
touch myapp.py | |
touch manage.py | |
Now the contents of the two files you touched. First the "hello world" Flask app goes in the myapp.py file:
Next we we take the tutorial Flask-Script manage.py file and adapt it very slightly:
Now we are ready to create a simple migration for a Post model for a blog:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "python ./manage.py migrate init" does not create the "migrations" directory for me! | |
mkdir migrations | |
python ./manage.py migrate create | |
Name for the migration: Post | |
Created new migration file: /mypath/migrations/0001_post.py |
and you get the template file which looks like this:
In the file put your Post model and modfy "up" and "down":
Our First Migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python ./manage.py migrate run |
Our Second Migration
Now if we want to modify that Post model we can again do:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python ./manage.py migrate create | |
Name for the migration: Post | |
Created new migration file: /mypath/migrations/0002_post.py |
modify your model and modfy "up" and "down", I've left some comments so you can see what I did:
and run it again.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python ./manage.py migrate run |
You should also play around with the "redo" and "undo" commands. That's about it really.
Conclusion
This is only version 0.6 of Flask-Evolution and it's got a way to go, but I can see some use in using it, but it's far from seamless and it's a long way from South.
Documentation is woeful and I'm not convinced the developer Adam Patterson has the time to do the job he'd like to.
You could always offer to give him a hand!
If you see anything wrong with what I've written here or if you spot spelling or other mistakes then please let me know.