Skip to main content

Database

Zander uses MySQL with Prisma as the ORM. This page documents the connection setup, how to apply migrations, and a full breakdown of every model in the schema so you know exactly where your data lives. The schema is defined in prisma/schema.prisma.

Connections

Three separate MySQL connections can be configured:

VariablePurpose
DATABASE_URLMain Zander database (required)
LUCKPERMS_URLLuckPerms database — used for rank/permission lookups (required if using ranks)
QUICKSHOP_URLQuickShop database — used for the shop directory (required if using shop directory)

Connection strings use the format:

mysql://username:password@host:3306/database_name

Initial Setup

Run the SQL initialisation script to create the base schema, then apply all numbered migrations from the migration/ directory in order:

mysql -u root -p zander < dbinit.sql
# then for each migration file in order:
mysql -u root -p zander < migration/001_name.sql

For new deployments using the Prisma build script:

npm run build

This runs prisma migrate deploy and prisma generate automatically.

Schema Overview

The following models are defined in prisma/schema.prisma:

Users & Authentication

ModelDescription
usersCore user accounts — UUID, username, email, password hash, profile data, social links
userEmailVerificationsEmail verification tokens
userPasswordResetsPassword reset tokens
userVerifyLinkShort-lived codes for linking Discord accounts to Minecraft UUIDs

Sessions

ModelDescription
sessionExpress session store (Prisma-backed)

Forums

ModelDescription
forumCategoriesForum categories with view/post permission nodes
forumDiscussionsDiscussion threads
forumPostsIndividual posts/replies
forumPostRevisionsEdit history for posts
forumPollsPolls embedded in discussions
forumPollOptionsPoll answer options
forumPollVotesUser vote records

Announcements & Servers

ModelDescription
announcementsMulti-type announcements (web, popup, tip, motd)
serversServer registry with connection details and type

Discord

ModelDescription
discord_punishmentsPunishment records (warn, kick, ban, mute) with expiry and status
discord_punishment_appealsAppeal submissions and review outcomes
scheduledDiscordMessagesScheduled message queue for the Discord scheduler

Support

ModelDescription
supportTicketsSupport ticket records with category and status
supportTicketMessagesMessages and internal notes within tickets

Reports & Punishments (Web)

ModelDescription
reportsPlayer reports submitted via web or Discord
punishmentsWeb-side punishments (warning, temp ban, permanent ban)

Voting

ModelDescription
votesIndividual vote records
vote_sitesConfigured voting sites
vote_reward_templatesCommand templates for vote and monthly rewards
vote_monthly_totalsAggregated monthly vote counts per player
vote_monthly_resultsProcessed monthly reward results
player_command_queueQueue of reward commands to execute in-game

Events

ModelDescription
eventsCommunity events with full lifecycle state
event_templatesRecurring event templates
event_hostsHost assignments for events
event_actionsIn-game actions triggered by events
event_announcementsDiscord/web announcements tied to events
event_audit_logsChange history for events

Creator Content

ModelDescription
creator_content_itemsCached Twitch/YouTube content items
user_platform_connectionsTwitch/YouTube account links for users

Bridge & Automation

ModelDescription
executorTasksIndividual command tasks in the bridge executor queue
executorRoutinesNamed multi-step routines for the bridge

Notifications

ModelDescription
userNotificationsIn-app notification records
pushSubscriptionsWeb push subscription endpoints per user

Migrations

Migration files are located in migration/. Run them in numeric order. After applying all migrations, the Prisma client must be regenerated:

npx prisma generate