-
Notifications
You must be signed in to change notification settings - Fork 0
Backend: Create a local PostgreSQL database
Since it's hard to produce universal instructions for both Linux and Windows, you'll need to google around yourself.
These instructions are only meant to be used to create a local instance of the Fizzyo database for development and testing. That is, all actions and commands mentioned here must be executed on your own laptop/PC and not the Fizzyo server.
-
First, you need to install PostgreSQL 9.6.
-
In PostgreSQL, create a user named
fizzyo_db
. Make sure that the new user is a superuser and that you spell the name correctly. -
Create a database named
fizzyo_db
. This step is required by postgres, we won't use this database in the future. -
Now you should be able to log in into PostgreSQL as the user we just created:
fizzyo_db
. Change the password to something simple (the password doesn't have to be secure since you are the only person who will access the database).- If you have access to the Postgres shell, you can use the \password command after logging in as
fizzyo_db
. - If you're on Linux, you might have to change the password twice: Once for the PostgreSQL user and once for the Unix user.
- If you have access to the Postgres shell, you can use the \password command after logging in as
-
Make sure you're logged in as
fizzyo_db
user, then create two databases – one for testing and the other for development. The respective SQL commands are:CREATE DATABASE fizzyo_local_test; CREATE DATABASE fizzyo_local_dev;
-
Now we need to upload a schema to
fizzyo_local_dev
and populate it with some dummy data. This is the bare minimum required for the app to function correctly. To do that, you'll need to go to yourFizzyo-backend
folder and execute thedb/schema.sql
anddb/dummy-data.sql
against the database, in that order.- To run an
.sql
script against the database, you can either usepsql
command line tool or use a PostgreSQL database editor like DataGrip. -
fizzyo_local_test
is populated automatically, so we don't need to do anything about it.
- To run an
-
Go to your local
Fizzyo-backend
install (step 2 from this guide). In yourconfig.json
, change two lines as shown below. I will assume your password is123456
, change it to match whatever you set."devDbUrl": "postgres://fizzyo_db:123456@localhost:5432/fizzyo_local_dev", "testDbUrl": "postgres://fizzyo_db:123456@localhost:5432/fizzyo_local_test",
- If you don't have a config.json, make a copy of config.example.json and renamed it into
config.json
.
- If you don't have a config.json, make a copy of config.example.json and renamed it into
-
Now, install all dependencies using
npm install
and run all tests usingnpm run test-all
. -
If all tests passed for you, you have successfully setup a local database instance.
If any of the documentation you see on this page is inaccurate, please create an issue or report it to Tim Kuzhagaliyev at tim.kuzhagaliyev.15 (at) ucl.ac.uk
.
- Meta:
- Tutorials:
- Notes:
- Coming soon.