Skip to main content

Overview

Hyperscape uses Drizzle ORM for database access:
  • Development: SQLite (zero config)
  • Production: PostgreSQL

Schema Location

Database schema is defined in:

Tables

Quest Tables

quest_progress - Tracks player quest state:
quest_audit_log - Immutable audit trail for security:

Characters Table Schema

The characters table stores all character data including skills:
Prayer Columns:
  • prayerLevel / prayerXp — Prayer skill progression
  • prayerPoints — Current prayer points (0 to prayerLevel)
  • prayerMaxPoints — Maximum prayer points (equals prayerLevel)
  • activePrayers — JSON array of active prayer IDs (e.g., '["thick_skin"]')
Prayer points are stored as integers in the database but tracked with fractional precision in-memory for accurate drain calculations.

Drizzle Commands

Run from packages/server/:

Push Schema

Apply schema changes directly (development):

Generate Migrations

Create migration files for changes:

Run Migrations

Apply pending migrations:

Studio

Open Drizzle Studio to browse data:

Configuration

packages/server/drizzle.config.ts:

Development vs Production

Development (SQLite)

No configuration needed—uses local SQLite file:

Production (PostgreSQL)

Set DATABASE_URL in environment:

Migrations

Migrations are stored in packages/server/src/database/migrations/:

Recent Migrations

Migration Format

Migrations use IF NOT EXISTS to be idempotent and safe to re-run. The --> statement-breakpoint comment is used by Drizzle to separate statements.

Migration Journal

Migrations must be registered in meta/_journal.json to run:
If you create a migration file but forget to add it to _journal.json, it will not run automatically.
The activePrayers column stores a JSON array of prayer IDs. Format: '["thick_skin", "burst_of_strength"]'. Empty array when no prayers are active: '[]'.

Schema Changes

1

Edit schema

Modify packages/server/src/database/schema.ts
2

Generate migration

3

Apply migration

4

Verify

Check that migration file was created in src/database/migrations/

Reset Database

Development Reset

Delete the SQLite file:

Docker PostgreSQL Reset

This permanently deletes all player data.

Backup and Restore

PostgreSQL Backup

PostgreSQL Restore

Troubleshooting

Schema Out of Sync

If you see schema errors after pulling updates:

Connection Refused

Ensure PostgreSQL is running:
If not running: