Skip to content

Database Schema Convention

Schema Source of Truth

Each module manages its own database schema under:

{module}/db/schema/{NN-category}/

Current Module Schema Directories

ModulePathDescription
slaunchx-app-prometheusslaunchx-app-prometheus/db/schema/Main application (13 categories, 47 tables)
slaunchx-support-solana-walletslaunchx-support-solana-wallet/db/schema/Solana wallet tables
slaunchx-support-tron-walletslaunchx-support-tron-wallet/db/schema/Tron wallet tables

Category Numbering (slaunchx-app-prometheus)

NumberCategoryTables
01api-authAPI authentication
03integrations-slashSlash connection + webhook
04sandboxSandbox data
05notificationsNotification channels
06transfersTransfer orders + tariffs
07institutionsInstitution management
08user-accountsUser accounts + OTP
09user-sessionsSession management
10user-permissionsPermission + roles
11workspacesWorkspace + invitations
12walletsWallet accounts + ledger
13billingRecharge/withdrawal/exchange/settlement
14file-storageFile record management

Schema File Format

Each .sql file:

  • One CREATE TABLE per file
  • Use CREATE TABLE IF NOT EXISTS for idempotent manual initialization
  • Include all indexes and constraints inline
  • File named after the table: recharge_channel.sql

Build Pipeline

  1. Python script generates jOOQ persistence code from all schema files: db/scripts/generate-jooq.py
  2. Output: generated persistence classes under src/main/java/com/slaunchx/core/persistence/generated/
  3. Schema changes require regeneration and atomic commit

Rules for Agents

  1. New table: create .sql in the appropriate numbered category directory
  2. New category: create new numbered directory (next available number)
  3. Schema changes: modify the source .sql file and add a matching changelog entry for ops
  4. Never edit: generated persistence code under persistence/generated/ (auto-generated)
  5. Test DB: uses schema source files, no separate test schema needed
  6. Cross-module: each module is independent, no cross-module schema references

Internal Handbook