Database Documentation #
BonsAI uses PostgreSQL for data persistence. This section covers the database schema, migration workflow, and management tools.
Database Technology #
- Database: PostgreSQL 15+
- Migration Tool: Atlas
- Management UI: CloudBeaver (accessible via Coder workspace)
- Connection Pooling: Built into BonsAPI
Documentation Sections #
- Database Schema - Complete table structures, relationships, and data models
- Database Migration - Schema migration workflow using Atlas
- CloudBeaver - Web-based database management tool for querying and exploring data
Quick Access #
From Your Coder Workspace #
- Click Database in your workspace dashboard
- Opens CloudBeaver in your browser
- Pre-configured connection to development database
Running Migrations #
cd ~/bonsai
mise run db:migrate
Atlas automatically applies pending migrations to your development database.
Common Tasks #
- View schema: Use CloudBeaver or
mise run db:inspect - Create migration: Edit schema in
/apps/bonsapi/migrations/and run Atlas - Reset database: Use Atlas to apply fresh schema (caution: destroys data)
- Query data: Use CloudBeaver for interactive SQL queries
Related Documentation #
- Example Workflow: Adding a New Field - Complete guide showing how to add a database column and run migrations
- BonsAPI Documentation - API that interacts with the database
- Infrastructure - Database deployment and configuration
- Development Workflow - How migrations fit into the dev process