-
Fork this repo
- Click
Forkin the top-right of the page - this will create a copy of this repo in your own GitHub account
- Click
-
Clone (download) the repo
- Go to your newly-created fork of the repo (on GitHub).
- Click
Clone or download(the green button on the right). - Make sure the page says
Clone with SSH(rather thanClone with HTTPS). - Open your git client (e.g. GitKraken) and use this link to clone the repo.
Your trainer will able to help you with this.
-
"Cloning the repo" will create a folder on your computer with the files from this repo.
Open this folder in Visual Studio Code. -
Open a command-prompt in this same folder.
Your trainer can show you how to do this, if you need any help. -
Run this command to set up the necessary dependencies:
poetry install -
Follow the instructions in the section
Setting up Postgresbelow to ensure that the database is ready for use. (You'll notice that your.envfile contains POSTGRES config variables. The instructions below setup a user to match that config, with the right permissions to create the database when the app runs.) -
Run this command to run your code:
poetry run flask run
Before you run the app you will need to make sure you've got Postgres installed and a database set up by following the instructions below.
-
Download and install the PostgreSQL server software if you haven't already.
-
Open the Windows Start menu and search for "pgAdmin". When you start "pgAdmin" for the first time, you'll be asked to set a master password.
-
Inside your PostgreSQL server in pgAdmin, right-click on Login/Group Roles and create a new Login/Group Role with the name
bookish(in the General tab), the passwordbookish(in the Definition tab) and the ability to log in and create databases (in the Privileges tab). -
Click
Saveto create the user.
-
Inside your PostgreSQL server in pgAdmin, right-click on Databases and create a new Database with the name
bookishand the ownerbookish(both in the General tab). -
Click
Saveto create the database.
-
The overall application framework is Flask, with routing setup in
app/__init.pyand page templates undertemplates/. -
SQL Alchemy is the ORM (Object-Relational Mapper) that provides object-based interaction with the database.
-
Migrations (database schema changes) are implemented with Alembic - see below.
Your migrations will run automatically at run-time to update your database with tables and data.
If you add a new model in the models directory, it's likely you'll want this to create a table in your database too! If you follow the steps below, your table should be created automatically on app start up (i.e. when you run poetry run flask run):
- Add your model to
models, for examplemodels/example.pywould includeclass Example(db.Model): ...which would in turn create the tableexample.- It's important to note here that your new class must extend
db.Model
- It's important to note here that your new class must extend
- Add your new file to the imports in
migrations/env.pyon line 35.
There are known limitations to Alembic's autogenerated migrations, so if you're having trouble make sure you check the docs linked above as a first stop.