Changes to config.py.
1. SQLALCHEMY_DATABASE_URI is required by flask-sqlalchemy.
2. SQLALCHEMY_MIGRATE_REPO is the folder where SQLAlchemy-migrate data files are stored.
3. We use sqlite for smaller applications. DB is stored in a single file named app.db here.
4. The ORM helps us to skip writing SQL and write in object-oriented lingo instead.
Changed the init script.
Added SQLAlchemy reference. Created database object by instantiating it with the Flask app object.
Also added import for 'models'.
Added models.py.
The User class inherits from db.Model. It contains column names as variables.
Parameters can be set in the db.Column constructor. By default, a user is not an admin.
Created a DB creation script.
db.create_all() generates the database.
If the MIGRATE_REPO path does not exist, it is created, and then added to version control.
If not, everything is just added to version control alongwith the version of MIGRATE_REPO.
Added a migration script generator script.
Any changes to DB structure are to be regarded as a migration. Our first migration takes us from an empty DB to one that can store users.
SQLAlchemy-migrate compares the structure of the DB against the structure of our models. The differences are recorded as a migration script ('script') inside the migration repo.
The migration script knows how to apply or undo a migration - allowing upgrade or downgrade of DB format.
Note: Don't rename existing fields, add or delete them, change their types if needed.
Made minor change in migration generator script.
Migrated DB to version 1.
Added upgrade and downgrade scripts.
These use the migration scripts generated in the migration repo by using the script generator which was made in the last commit.
Added a Post class which inherits from db.Model.
It represents blog posts, and its user_id field has been initialized as a foreign key.
The User class gets a field 'posts', which is a db.relationship field. For a one to many relationship, the db.relationship field is defined on the "one" side.
This relationship gives us a user.posts member from which we can list the posts of a particular user.
db.relationship(name of 'many' class, backref=field that will be added to objects of 'many' class that points back at the 'one' object or post.author, lazy).
Upgraded DB version to 2.
Played around with the database using sessions.
Added a text file of the run.
Merge pull request #2 from VaticanCameos/ch4

Adding chapter 4