Database Schema
Overview
Section titled “Overview”Plugins can access the database using Prisma client. Each plugin should namespace its tables to avoid conflicts.
Accessing Prisma
Section titled “Accessing Prisma”import { prisma } from '@aether/database';
// Query dataconst entries = await prisma.timerEntry.findMany({ where: { workUnitId },});
// Create dataconst entry = await prisma.timerEntry.create({ data: { workUnitId, startTime: new Date(), },});Plugin Table Naming Convention
Section titled “Plugin Table Naming Convention”Prefix all plugin tables with plugin_<slug>_:
CREATE TABLE plugin_timer_entries (...);CREATE TABLE plugin_tasks_items (...);CREATE TABLE plugin_analytics_reports (...);Core Schema Reference
Section titled “Core Schema Reference”Work Units
Section titled “Work Units”workUnits- Main work unit tableid,name,status,businessType,organizationId,customerId
Customers
Section titled “Customers”customers- Customer/client tableid,name,email,organizationId
Organizations
Section titled “Organizations”organizations- Organization/tenant tableid,name,businessType,premiumTier
users- User accountsid,name,email
Best Practices
Section titled “Best Practices”- Always filter by
organizationIdfor multi-tenancy - Use transactions for multi-step operations
- Add indexes for frequently queried columns
- Use foreign keys with CASCADE delete
- Namespace your tables with
plugin_prefix