Mellow LogoMellow

Database Schema

Mellow's PostgreSQL schema.

Database schema

Mellow uses PostgreSQL. The schema is defined by versioned SQL migrations in internal/db/migrations (golang-migrate), embedded in the binary and applied on startup. Queries are generated from internal/db/queries by sqlc; there is no ORM.

Identifiers are quoted and mixed-case ("User", "MoodCheckIn", "createdAt") because the schema is a faithful reproduction of Mellow's earlier Prisma schema, so an existing production database keeps working unchanged.

Tables

TablePurpose
MellowSingle-row AI configuration (model, prompt, temperature, maxTokens, feature flags, owners).
UserOne row per Discord user Mellow has seen (id is the Discord ID). Includes Mellow-level ban fields and role.
GuildOne row per server. Feature toggles, channel IDs, moderator role, language, Mellow-level ban fields.
UserPreferencesPer-user settings: checkInInterval (minutes, default 720), reminder settings, aiPersonality, timezone, and the disableContextLogging / disableCrisisDetection / disableCrisisSupportDMs toggles.
ConversationHistoryStored messages for AI context (content encrypted). Threaded via parentId, typed via contextType, optional metadata JSONB.
MoodCheckInCheck-ins: mood, intensity, activity, note (mood/activity/note encrypted), nextCheckIn.
CopingToolUsageOne row per coping tool use (toolName, usedAt).
FavoriteCopingToolA user's toolbox entries.
CopingPlanA user's personal coping plan (plan encrypted).
JournalEntryJournal entries (content encrypted).
GratitudeEntryGratitude entries (item encrypted).
GhostLetterGhost letters (content encrypted).
CrisisEventCrisis screening events (details encrypted, escalated flag).
Feedback / FeedbackReply/feedback submissions and staff replies (message encrypted). Approval, public, and featured flags drive the testimonials API.
Report / ReportReply/report submissions and staff replies (message encrypted), with a status.
SystemLogInternal operational log entries (gateway, guild, command, crisis, system, startup, shutdown).
ModActionLegacy table retained for database compatibility. The Go bot does not write to it.

Enums

  • Role - OWNER, ADMIN, MOD, SUPPORT, SYSTEM, USER. Mellow's internal role for command gating; unrelated to Discord roles.

Legacy fields

Some columns exist only for compatibility with the earlier schema and are unused by the Go bot, including Mellow.presencePenalty / Mellow.frequencyPenalty (no Anthropic equivalent) and Guild.autoModEnabled / Guild.autoModLevel / Guild.systemRoleId (Mellow has no auto-moderation or auto-role features).

Encrypted fields

See

Data Protection

Data Protection

How Mellow encrypts and stores your data.

for the full list and the encryption scheme. Non-sensitive columns are stored in the clear so the app can query them.

Source of truth

The migration files in internal/db/migrations/0001_baseline.up.sql (and any later migrations) are authoritative. This page is a summary.

On this page