Skip to content

Database setup

This guide will help you install and setup PostgreSQL for hosting the database locally.

  1. Open a terminal and run the following commands to install PostgreSQL:

    Terminal window
    sudo apt update
    sudo apt install postgresql-16
  2. Run sudo -u postgres psql --version to ensure PostgreSQL was installed properly. It should print that the major version is 16.

  3. Run the following commands to setup PostgreSQL for the ground station.

    Terminal window
    # Connect to PostgreSQL CLI as the postgres superuser
    sudo -u postgres psql
    # Replace your_username and your_password with your desired values
    CREATE USER your_username WITH PASSWORD 'your_password' SUPERUSER;
    CREATE DATABASE gs;
  4. Log out, then verify that you can log in to your newly created user and database:

    Terminal window
    \q # Log out
    # Replace your_username with your actual username
    psql -U your_username -d gs
    # You should be logged into the database
    \q # Log out again
  5. From the root directory, run the following commands to create a new .env file:

    Terminal window
    cd gs/backend/config
    cp template.env .env
  6. Edit the .env file to add your login details in the quotes. In Linux/WSL, you can use vim or nano.

  7. Ensure that your Python virtual environment is activated. If not, follow Initial setup. Start the backend in development mode by running fastapi dev gs/backend/main.py from the root directory. This will also initialize the database.