# Database

QuickDapp supports PostgreSQL databases by default, with Prisma as the ORM layer.

Technically speaking, any database type supported by Prisma could be used, although note that some of the DigitalOcean database-related commands (e.g do-cloud) will then require modification.

# Connection parameters

The database connection parameters are supplied as the DATABASE_URL environment variable, e.g:

DATABASE_URL=postgresql://postgres:@localhost:5432/quickdapp?schema=public

# Schema

A number of built-in tables are provided for your convenince:

  • Setting - for any persisted app-level settings as key-value pairs.
  • User - for authenticated users - includes a field for storing the user's wallet address and any settings field which can hold any JSON data.
  • Notification - for notifying users with a message or other data.
  • WorkerJob - for the background worker task queue.

# Accessing

All database tables are accessed through purpose-built model code found in src/backend/db. This provides for an abstraction layer over the database which hids the raw Prisma commands from other backend code. Each model function excpets a db parameter which can be obtained from the bootstrap object.

# Local development

To migrate the database to the latest schema:

pnpm dev db migrate

To reset the database to the latest schema and clear all of its data:

pnpm dev db reset

To re-generate the Prisma client and associated Typescript bindings:

pnpm dev db generate-types

# Production deployment

For the production database only a migration/upgrade ability is provided.

To migrate the database to the latest schema:

pnpm prod db migrate