Skip to content

mahd-dev/riwaq-pg

Repository files navigation

Riwaq-PG: PostgreSQL, PostGraphile, and Prisma Stack

GitHub license

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.

📌 Prerequisites

Before getting started, ensure you have the following tools installed on your machine:

  1. Docker & Docker Compose: This project uses Docker to containerize the services. Install Docker from here and Docker Compose from here.

  2. Node.js: Our scripts and dependencies require Node.js. Download and install it from nodejs.org.

  3. Yarn: This project recommends using yarn as the package manager. Install it by running npm install -g yarn or follow the official documentation.

  4. 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.

🚀 Getting Started

1. Use this Template:

Start by creating your own repository using the Riwaq-PG template.

2. Clone Your Repository:

git clone [YOUR-NEW-REPOSITORY-URL] && cd [YOUR-NEW-REPOSITORY-DIRECTORY]

3. Run the Realtime-enabled Postgres Locally:

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.

4. Install dependencies:

yarn install

5. Create .env file:

Create your .env file from .env.example:

cp .env.example .env

6. Sync schema:

This will synchronize the predefined example schema containing the Org table to your deployed database:

yarn push

7. Start the server:

yarn start

8. Browse & use the API:

Tada! you have a fully working GraphQL API under http://localhost:5000/graphql

You can explore use the GraphiQL under: http://localhost:5000

📝 Define Your Database Schema

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.

📜 Scripts Explanation

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.

🧐 Need More Help?

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 😛 🚀

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published