adidoesnt / ourfinals

An on-demand peer tutoring platform by students, for students.
4 stars 1 forks source link

OURFinals

An on-demand peer tutoring platform by students, for students.

Database

The prisma/ folder contains:

PostgreSQL setup guide

(Some of these steps are specific to MacOS)

  1. Install the PostgressApp and psql CLI from postgresapp.com.

  2. Create a database. First enter Postgres by typing psql in the terminal, then run CREATE DATABASE ourfinals;

  3. Verify that the database has been created via PostgressApp.

  4. (I have already done this, but I'm keeping it here for reference)

    Create the file prisma/seed.js and add some seed data. (Seed DB docs)

    Add this section to package.json:

    {
      ...,
      "prisma": {
          "seed": "node prisma/seed.js"
      },
    }
  5. Make a migration.

    This only needs to be done when the schema is changed. I have already made the first migration (first_migration).

    To make a migration, run

    npx prisma migrate dev --name migrationname

    (Can use npm run db:migrate, and it'll prompt you for a migration name)

    There is no need put the data in the migration name as it's already included in the resulting migration folder name.

    Additionally, if the local database hasn't been created, this command should create it.

    This will also run the seeding script (made in the previous step).

  6. To reset the database, run npm db:reset. This will drop the DB (or perform a soft reset), create the DB again, apply all migrations, then run the seed script (Reset command docs).