Welcome to the Riwaq-PG template repository! This setup offers a seamless development experience for a stateful database schema using PostgreSQL PostGraphile, and Prisma that reflects immediately as a real-time GraphQL API. you'll be up and running in no time.
Before getting started, ensure you have the following tools installed on your machine:
-
Docker & Docker Compose: This project uses Docker to containerize the services. Install Docker from here and Docker Compose from here.
-
Node.js: Our scripts and dependencies require Node.js. Download and install it from nodejs.org.
-
Yarn: This project recommends using
yarn
as the package manager. Install it by runningnpm install -g yarn
or follow the official documentation. -
Git: Ensure you have Git installed for version control. If not, you can download it from git-scm.com.
Once all prerequisites are met, you can proceed to the next steps.
Start by creating your own repository using the Riwaq-PG template.
git clone [YOUR-NEW-REPOSITORY-URL] && cd [YOUR-NEW-REPOSITORY-DIRECTORY]
Use the following command to run the Realtime-enabled Postgres:
docker compose -p [MY-PROJECT-NAME] up -d
Replace
[MY-PROJECT-NAME]
with a name of your choice for the project. This name will be used as a prefix for your containers.
yarn install
Create your .env
file from .env.example
:
cp .env.example .env
This will synchronize the predefined example schema containing the Org
table to your deployed database:
yarn push
yarn start
Tada! you have a fully working GraphQL API under http://localhost:5000/graphql
You can explore use the GraphiQL under: http://localhost:5000
The heart of your project lies in the schema.prisma
file. This is where you'll define your database schema. Once you've outlined your schema:
Create migrations using the following command:
yarn migrate [MY_MIGRATION_NAME]
Replace [MY_MIGRATION_NAME]
with a descriptive name for your migration.
There is a collection of scripts tailored to manage and manipulate your Prisma and your database schema:
- status: Check the status of your migrations.
- diff: Check the difference between the current state of the database and the Prisma schema.
- migrate: Create and run migrations for your database. example
yarn migrate create_table_x
- reset: Reset your database and apply all migrations from scratch.
- deploy: Apply pending migrations to update the database schema.
- pull: Update the Prisma schema based on the current state of the database.
- push: Update the database schema to match the Prisma schema without creating a migration.
- seed: Seed your database with data specified in
seed.ts
. - execute: Execute raw SQL queries directly on your database.
- generate: Generate Prisma Client based on your current Prisma schema.
- validate: Validate your Prisma schema.
- format: Correctly format your Prisma schema.
- studio: Open Prisma Studio, a visual interface for your database.
If you have questions or run into issues, feel free to raise an issue on the Riwaq-PG repository or consult the official documentation for PostgreSQL, PostGraphile, and Prisma.
Thank you for choosing Riwaq-PG! Happy migrating 😛 🚀