TUTORIAL 02 · BEGINNER
Build a PostgreSQL CRUD Application
Move ServiceDesk from memory storage to PostgreSQL with generated Prisma persistence and Docker-backed local development.
By the end of this tutorial
- Select PostgreSQL persistence
- Generate Prisma-backed CRUD
- Start PostgreSQL with Docker
- Understand DATABASE_URL as a secret contract
Switch to PostgreSQL
PostgreSQL changes persistence from an in-process store to a database-backed generated application. DATABASE_URL is declared as a secret name rather than embedded as a value.
app.raiql
CREATE APPLICATION "RAIQL ServiceDesk";
TYPE WEB;
USE STACK
FRONTEND NEXTJS,
BACKEND NEXTJS,
DATABASE POSTGRESQL;
CREATE ENTITY Ticket (
id UUID PRIMARY,
title STRING REQUIRED,
description STRING,
status STRING REQUIRED,
priority STRING REQUIRED
);
CREATE CRUD Ticket;
CREATE API Ticket;
SECRET DATABASE_URL;
BUILD;
DEPLOY DOCKER;Check Docker first
Generated PostgreSQL projects use Docker for the local database workflow. RAIQL doctor catches missing Docker or an inactive daemon before the generated app starts.
terminal
raiql doctor
open -a Docker # macOS
docker infoGenerate the persistence layer
Generation produces the Prisma schema, database client, CRUD APIs, Docker Compose configuration and environment contract.
terminal
raiql validate
raiql generate
find generated/prisma generated/app/api -maxdepth 3 -type f | sortRun the database-backed app
terminal
raiql env init development
raiql env check development
raiql dev --env developmentInspect the generated database
The generated project also exposes database helper commands, including Prisma Studio when using the PostgreSQL adapter.
terminal
cd generated
npm run db:studio