Skip to content

Database Schema

Plugins can access the database using Prisma client. Each plugin should namespace its tables to avoid conflicts.

import { prisma } from '@aether/database';
// Query data
const entries = await prisma.timerEntry.findMany({
where: { workUnitId },
});
// Create data
const entry = await prisma.timerEntry.create({
data: {
workUnitId,
startTime: new Date(),
},
});

Prefix all plugin tables with plugin_<slug>_:

CREATE TABLE plugin_timer_entries (...);
CREATE TABLE plugin_tasks_items (...);
CREATE TABLE plugin_analytics_reports (...);
  • workUnits - Main work unit table
  • id, name, status, businessType, organizationId, customerId
  • customers - Customer/client table
  • id, name, email, organizationId
  • organizations - Organization/tenant table
  • id, name, businessType, premiumTier
  • users - User accounts
  • id, name, email
  • Always filter by organizationId for 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