48 KiB
Database Schema
Generated from the Sequelize models (
backend/src/db/models/*) — the source of truth. Regenerate after schema changes. Last generated: 2026-06-09.
Overview
- Engine: PostgreSQL via Sequelize 6 (models in
backend/src/db/models, typed data access inbackend/src/db/api). - Models: 38 tables.
- Primary keys: every table has a
uuidid(defaultUUIDV4). - Soft delete: all tables are
paranoid— rows are flagged withdeletedAtinstead of being physically removed. - Timestamps:
createdAt/updatedAtare managed automatically. - Audit:
createdById/updatedByIdreferenceusers(aliasescreatedBy/updatedBy). - Multi-tenancy: tenant-owned tables carry
organizationIdand are scoped to the current user's organization indb/api(seefull-integration-refactor-plan.md, tenant boundary workstream). - Import idempotency:
importHash(unique) deduplicates seeded/imported rows.
Type notes
Types below are the SQL column types. A few Sequelize types are returned as JS string at runtime to preserve precision: DECIMAL, NUMERIC, BIGINT, and DATEONLY (date-only). DATE maps to a JS Date.
Domains
- Tenancy & Access:
organizations,users,roles,permissions - Campuses & People:
campuses,students,guardians,staff - Academics:
academic_years,grades,subjects,classes,class_enrollments,class_subjects,timetables,timetable_periods,assessments,assessment_results - Attendance:
attendance_sessions,attendance_records,campus_attendance_config,campus_attendance_summaries,staff_attendance_records - Finance / Billing:
fee_plans,invoices,payments - Communication:
messages,message_recipients,communication_events - Content & Product modules:
content_catalog,documents,frame_entries,user_progress,safety_quiz_results,walkthrough_checkins,personality_quiz_results - System:
file,auth_refresh_tokens
Relationship graph (foreign keys)
Each edge is a belongsTo (the child holds the FK). createdBy / updatedBy edges to users are omitted for readability.
erDiagram
organizations ||--o{ academic_years : "organization"
organizations ||--o{ assessment_results : "organization"
assessments ||--o{ assessment_results : "assessment"
students ||--o{ assessment_results : "student"
organizations ||--o{ assessments : "organization"
class_subjects ||--o{ assessments : "class_subject"
organizations ||--o{ attendance_records : "organization"
attendance_sessions ||--o{ attendance_records : "attendance_session"
students ||--o{ attendance_records : "student"
organizations ||--o{ attendance_sessions : "organization"
campuses ||--o{ attendance_sessions : "campus"
classes ||--o{ attendance_sessions : "class"
class_subjects ||--o{ attendance_sessions : "class_subject"
staff ||--o{ attendance_sessions : "taken_by"
users ||--o{ auth_refresh_tokens : "user"
organizations ||--o{ auth_refresh_tokens : "organization"
organizations ||--o{ campus_attendance_config : "organization"
campuses ||--o{ campus_attendance_config : "campus"
organizations ||--o{ campus_attendance_summaries : "organization"
campuses ||--o{ campus_attendance_summaries : "campus"
organizations ||--o{ campuses : "organization"
organizations ||--o{ class_enrollments : "organization"
classes ||--o{ class_enrollments : "class"
students ||--o{ class_enrollments : "student"
organizations ||--o{ class_subjects : "organization"
classes ||--o{ class_subjects : "class"
subjects ||--o{ class_subjects : "subject"
staff ||--o{ class_subjects : "teacher"
organizations ||--o{ classes : "organization"
campuses ||--o{ classes : "campus"
academic_years ||--o{ classes : "academic_year"
grades ||--o{ classes : "grade"
staff ||--o{ classes : "homeroom_teacher"
organizations ||--o{ communication_events : "organization"
campuses ||--o{ communication_events : "campus"
organizations ||--o{ documents : "organization"
campuses ||--o{ documents : "campus"
organizations ||--o{ fee_plans : "organization"
academic_years ||--o{ fee_plans : "academic_year"
grades ||--o{ fee_plans : "grade"
organizations ||--o{ frame_entries : "organization"
campuses ||--o{ frame_entries : "campus"
organizations ||--o{ grades : "organization"
organizations ||--o{ guardians : "organization"
students ||--o{ guardians : "student"
organizations ||--o{ invoices : "organization"
campuses ||--o{ invoices : "campus"
students ||--o{ invoices : "student"
fee_plans ||--o{ invoices : "fee_plan"
organizations ||--o{ message_recipients : "organization"
messages ||--o{ message_recipients : "message"
organizations ||--o{ messages : "organization"
campuses ||--o{ messages : "campus"
users ||--o{ messages : "sent_by"
organizations ||--o{ payments : "organization"
invoices ||--o{ payments : "invoice"
staff ||--o{ payments : "received_by"
organizations ||--o{ personality_quiz_results : "organization"
campuses ||--o{ personality_quiz_results : "campus"
users ||--o{ personality_quiz_results : "user"
organizations ||--o{ safety_quiz_results : "organization"
campuses ||--o{ safety_quiz_results : "campus"
users ||--o{ safety_quiz_results : "user"
organizations ||--o{ staff : "organization"
campuses ||--o{ staff : "campus"
users ||--o{ staff : "user"
organizations ||--o{ staff_attendance_records : "organization"
campuses ||--o{ staff_attendance_records : "campus"
users ||--o{ staff_attendance_records : "user"
organizations ||--o{ students : "organization"
campuses ||--o{ students : "campus"
organizations ||--o{ subjects : "organization"
organizations ||--o{ timetable_periods : "organization"
timetables ||--o{ timetable_periods : "timetable"
class_subjects ||--o{ timetable_periods : "class_subject"
organizations ||--o{ timetables : "organization"
campuses ||--o{ timetables : "campus"
academic_years ||--o{ timetables : "academic_year"
organizations ||--o{ user_progress : "organization"
campuses ||--o{ user_progress : "campus"
users ||--o{ user_progress : "user"
roles ||--o{ users : "app_role"
organizations ||--o{ users : "organizations"
organizations ||--o{ walkthrough_checkins : "organization"
campuses ||--o{ walkthrough_checkins : "campus"
Table reference
Tenancy & Access
organizations
Tenant root. Every tenant-owned row references an organization via organizationId.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
usersasusers_organizations(FKorganizationId) - has many
campusesascampuses_organization(FKorganizationId) - has many
academic_yearsasacademic_years_organization(FKorganizationId) - has many
gradesasgrades_organization(FKorganizationId) - has many
subjectsassubjects_organization(FKorganizationId) - has many
studentsasstudents_organization(FKorganizationId) - has many
guardiansasguardians_organization(FKorganizationId) - has many
staffasstaff_organization(FKorganizationId) - has many
classesasclasses_organization(FKorganizationId) - has many
class_enrollmentsasclass_enrollments_organization(FKorganizationId) - has many
class_subjectsasclass_subjects_organization(FKorganizationId) - has many
timetablesastimetables_organization(FKorganizationId) - has many
timetable_periodsastimetable_periods_organization(FKorganizationId) - has many
attendance_sessionsasattendance_sessions_organization(FKorganizationId) - has many
attendance_recordsasattendance_records_organization(FKorganizationId) - has many
fee_plansasfee_plans_organization(FKorganizationId) - has many
invoicesasinvoices_organization(FKorganizationId) - has many
paymentsaspayments_organization(FKorganizationId) - has many
assessmentsasassessments_organization(FKorganizationId) - has many
assessment_resultsasassessment_results_organization(FKorganizationId) - has many
messagesasmessages_organization(FKorganizationId) - has many
message_recipientsasmessage_recipients_organization(FKorganizationId) - has many
documentsasdocuments_organization(FKorganizationId)
users
Authentication identities. email is required (login + primary contact). Belongs to one organization (organizationId, alias organizations), one app_role, and may hold direct custom_permissions.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
firstName |
text | yes | — | |
lastName |
text | yes | — | |
phoneNumber |
text | yes | — | |
email |
text | no | — | |
disabled |
boolean | no | false | |
password |
text | yes | — | |
emailVerified |
boolean | no | false | |
emailVerificationToken |
text | yes | — | |
emailVerificationTokenExpiresAt |
timestamptz | yes | — | |
passwordResetToken |
text | yes | — | |
passwordResetTokenExpiresAt |
timestamptz | yes | — | |
provider |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
app_roleId |
uuid | yes | — | FK |
Relations:
- many-to-many with
permissionsascustom_permissions(FKusers_custom_permissionsId) - many-to-many with
permissionsascustom_permissions_filter(FKusers_custom_permissionsId) - has many
staffasstaff_user(FKuserId) - has many
messagesasmessages_sent_by(FKsent_byId) - belongs to
rolesasapp_role(FKapp_roleId) - belongs to
organizationsasorganizations(FKorganizationId) - has many
fileasavatar(FKbelongsToId)
roles
Named permission sets (RBAC). Linked to permissions M:N; globalAccess grants cross-tenant access.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
globalAccess |
boolean | no | false | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- many-to-many with
permissionsaspermissions(FKroles_permissionsId) - many-to-many with
permissionsaspermissions_filter(FKroles_permissionsId) - has many
usersasusers_app_role(FKapp_roleId)
permissions
Flat permission catalog. Permission names follow ${METHOD}_${ENTITY} (e.g. READ_CAMPUSES).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Campuses & People
campuses
A physical or online campus belonging to one organization. Parent of students, staff, classes, etc.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
code |
text | yes | — | |
address |
text | yes | — | |
phone |
text | yes | — | |
email |
text | yes | — | |
mascot |
text | yes | — | |
color |
text | yes | — | |
bgGradient |
text | yes | — | |
borderColor |
text | yes | — | |
textColor |
text | yes | — | |
bgLight |
text | yes | — | |
description |
text | yes | — | |
isOnline |
boolean | no | false | |
active |
boolean | no | false | |
importHash |
varchar | yes | — | unique, audit |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
Relations:
- has many
studentsasstudents_campus(FKcampusId) - has many
staffasstaff_campus(FKcampusId) - has many
classesasclasses_campus(FKcampusId) - has many
timetablesastimetables_campus(FKcampusId) - has many
attendance_sessionsasattendance_sessions_campus(FKcampusId) - has many
invoicesasinvoices_campus(FKcampusId) - has many
messagesasmessages_campus(FKcampusId) - has many
documentsasdocuments_campus(FKcampusId) - belongs to
organizationsasorganization(FKorganizationId)
students
Enrolled students. Belong to a campus and organization; have guardians, enrollments, attendance, results, invoices.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
student_number |
text | yes | — | |
first_name |
text | yes | — | |
last_name |
text | yes | — | |
gender |
enum | yes | — | |
date_of_birth |
timestamptz | yes | — | |
enrollment_date |
timestamptz | yes | — | |
status |
enum | yes | — | |
email |
text | yes | — | |
phone |
text | yes | — | |
address |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
guardiansasguardians_student(FKstudentId) - has many
class_enrollmentsasclass_enrollments_student(FKstudentId) - has many
attendance_recordsasattendance_records_student(FKstudentId) - has many
invoicesasinvoices_student(FKstudentId) - has many
assessment_resultsasassessment_results_student(FKstudentId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - has many
fileasphoto(FKbelongsToId)
guardians
Guardians/contacts linked to a student.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
full_name |
text | yes | — | |
relationship |
enum | yes | — | |
phone |
text | yes | — | |
email |
text | yes | — | |
address |
text | yes | — | |
primary_contact |
boolean | no | false | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
studentId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
studentsasstudent(FKstudentId)
staff
Staff members, optionally linked to a user account; can be homeroom teacher, subject teacher, attendance taker, payment receiver.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
employee_number |
text | yes | — | |
job_title |
text | yes | — | |
staff_type |
enum | yes | — | |
hire_date |
timestamptz | yes | — | |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
userId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
classesasclasses_homeroom_teacher(FKhomeroom_teacherId) - has many
class_subjectsasclass_subjects_teacher(FKteacherId) - has many
attendance_sessionsasattendance_sessions_taken_by(FKtaken_byId) - has many
paymentsaspayments_received_by(FKreceived_byId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersasuser(FKuserId) - has many
fileasphoto(FKbelongsToId)
Academics
academic_years
School years (with current flag and effective dates) scoping classes, timetables, fee plans.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
start_date |
timestamptz | yes | — | |
end_date |
timestamptz | yes | — | |
current |
boolean | no | false | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
classesasclasses_academic_year(FKacademic_yearId) - has many
timetablesastimetables_academic_year(FKacademic_yearId) - has many
fee_plansasfee_plans_academic_year(FKacademic_yearId) - belongs to
organizationsasorganization(FKorganizationId)
grades
Grade levels (with sort_order).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
code |
text | yes | — | |
sort_order |
integer | yes | — | |
description |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
classesasclasses_grade(FKgradeId) - has many
fee_plansasfee_plans_grade(FKgradeId) - belongs to
organizationsasorganization(FKorganizationId)
subjects
Academic subjects (Math, English, …).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
code |
text | yes | — | |
description |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
class_subjectsasclass_subjects_subject(FKsubjectId) - belongs to
organizationsasorganization(FKorganizationId)
classes
Class/group: belongs to campus, academic year, grade, and a homeroom teacher.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
section |
text | yes | — | |
capacity |
integer | yes | — | |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
academic_yearId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
gradeId |
uuid | yes | — | FK |
homeroom_teacherId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
class_enrollmentsasclass_enrollments_class(FKclassId) - has many
class_subjectsasclass_subjects_class(FKclassId) - has many
attendance_sessionsasattendance_sessions_class(FKclassId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
academic_yearsasacademic_year(FKacademic_yearId) - belongs to
gradesasgrade(FKgradeId) - belongs to
staffashomeroom_teacher(FKhomeroom_teacherId)
class_enrollments
Join of student ↔ class with enrolment dates and status.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
enrolled_on |
timestamptz | yes | — | |
ended_on |
timestamptz | yes | — | |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
classId |
uuid | yes | — | FK |
studentId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
classesasclass(FKclassId) - belongs to
studentsasstudent(FKstudentId)
class_subjects
Join of class ↔ subject ↔ teacher; the unit that schedule, attendance, and assessments hang off.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
classId |
uuid | yes | — | FK |
subjectId |
uuid | yes | — | FK |
teacherId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
timetable_periodsastimetable_periods_class_subject(FKclass_subjectId) - has many
attendance_sessionsasattendance_sessions_class_subject(FKclass_subjectId) - has many
assessmentsasassessments_class_subject(FKclass_subjectId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
classesasclass(FKclassId) - belongs to
subjectsassubject(FKsubjectId) - belongs to
staffasteacher(FKteacherId)
timetables
A timetable for a campus + academic year, with effective dates.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
effective_from |
timestamptz | yes | — | |
effective_to |
timestamptz | yes | — | |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
academic_yearId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
timetable_periodsastimetable_periods_timetable(FKtimetableId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
academic_yearsasacademic_year(FKacademic_yearId)
timetable_periods
A single period (day/time/room) linking a timetable to a class_subject.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
day_of_week |
enum | yes | — | |
starts_at |
timestamptz | yes | — | |
ends_at |
timestamptz | yes | — | |
room |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
class_subjectId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
timetableId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
timetablesastimetable(FKtimetableId) - belongs to
class_subjectsasclass_subject(FKclass_subjectId)
assessments
Assessments for a class_subject (type, dates, max score, attachments).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
assessment_type |
enum | yes | — | |
assigned_at |
timestamptz | yes | — | |
due_at |
timestamptz | yes | — | |
max_score |
decimal | yes | — | |
status |
enum | yes | — | |
instructions |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
class_subjectId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
assessment_resultsasassessment_results_assessment(FKassessmentId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
class_subjectsasclass_subject(FKclass_subjectId) - has many
fileasattachments(FKbelongsToId)
assessment_results
A student's result for an assessment (score, grade_letter).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
score |
decimal | yes | — | |
grade_letter |
enum | yes | — | |
remarks |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
assessmentId |
uuid | yes | — | FK |
studentId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
assessmentsasassessment(FKassessmentId) - belongs to
studentsasstudent(FKstudentId)
Attendance
attendance_sessions
An attendance session for a class/class_subject taken by a staff member.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
session_date |
timestamptz | yes | — | |
session_type |
enum | yes | — | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
classId |
uuid | yes | — | FK |
class_subjectId |
uuid | yes | — | FK |
taken_byId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
attendance_recordsasattendance_records_attendance_session(FKattendance_sessionId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
classesasclass(FKclassId) - belongs to
class_subjectsasclass_subject(FKclass_subjectId) - belongs to
staffastaken_by(FKtaken_byId)
attendance_records
Per-student attendance within a session (status, minutes_late).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
status |
enum | yes | — | |
minutes_late |
integer | yes | — | |
remarks |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
attendance_sessionId |
uuid | yes | — | FK |
studentId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
attendance_sessionsasattendance_session(FKattendance_sessionId) - belongs to
studentsasstudent(FKstudentId)
campus_attendance_config
Product-module config for campus attendance.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
campus_key |
text | no | — | |
attendance_link |
text | yes | — | |
updated_by_label |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId)
campus_attendance_summaries
Product-module aggregated campus attendance.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
campus_key |
text | no | — | |
attendance_date |
date | no | — | |
total_enrolled |
integer | no | — | |
total_present |
integer | no | — | |
total_absent |
integer | no | — | |
total_tardy |
integer | no | 0 | |
attendance_percentage |
decimal | no | — | |
recorded_by_label |
text | yes | — | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId)
staff_attendance_records
Staff attendance records (present/late/absent).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
attendance_date |
date | no | — | |
status |
enum | no | — | |
note |
text | yes | — | |
user_name |
text | no | — | |
user_role |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
userId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersasuser(FKuserId)
Finance / Billing
fee_plans
Fee/tuition plans (billing cycle, total amount) for a grade in an academic year. Invoices are generated from these.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
name |
text | yes | — | |
billing_cycle |
enum | yes | — | |
total_amount |
decimal | yes | — | |
active |
boolean | no | false | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
academic_yearId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
gradeId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
invoicesasinvoices_fee_plan(FKfee_planId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
academic_yearsasacademic_year(FKacademic_yearId) - belongs to
gradesasgrade(FKgradeId)
invoices
Invoices issued to a student (amounts, status) — optionally from a fee_plan.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
invoice_number |
text | yes | — | |
issue_date |
timestamptz | yes | — | |
due_date |
timestamptz | yes | — | |
subtotal |
decimal | yes | — | |
discount_amount |
decimal | yes | — | |
tax_amount |
decimal | yes | — | |
total_amount |
decimal | yes | — | |
balance_due |
decimal | yes | — | |
status |
enum | yes | — | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
campusId |
uuid | yes | — | FK |
fee_planId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
studentId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
paymentsaspayments_invoice(FKinvoiceId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
studentsasstudent(FKstudentId) - belongs to
fee_plansasfee_plan(FKfee_planId) - has many
fileasattachments(FKbelongsToId)
payments
Payments against an invoice (amount, method, proof file).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
receipt_number |
text | yes | — | |
paid_at |
timestamptz | yes | — | |
amount |
decimal | yes | — | |
method |
enum | yes | — | |
reference_code |
text | yes | — | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
invoiceId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
received_byId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
invoicesasinvoice(FKinvoiceId) - belongs to
staffasreceived_by(FKreceived_byId) - has many
fileasproof(FKbelongsToId)
Communication
messages
In-app announcements/messages (subject/body/channel/audience) with attachments and recipients.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
subject |
text | yes | — | |
body |
text | yes | — | |
channel |
enum | yes | — | |
audience |
enum | yes | — | |
sent_at |
timestamptz | yes | — | |
status |
enum | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
sent_byId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- has many
message_recipientsasmessage_recipients_message(FKmessageId) - belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersassent_by(FKsent_byId) - has many
fileasattachments(FKbelongsToId)
message_recipients
Per-recipient delivery/read tracking for a message (in-app).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
recipient_type |
enum | yes | — | |
recipient_label |
text | yes | — | |
destination |
text | yes | — | |
delivery_status |
enum | yes | — | |
delivered_at |
timestamptz | yes | — | |
read_at |
timestamptz | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
messageId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
messagesasmessage(FKmessageId)
communication_events
Product-module communication events (meetings, drills, events, deadlines).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
title |
text | no | — | |
event_date |
date | no | — | |
event_type |
text | no | — | |
roles |
jsonb | no | Array | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId)
Content & Product modules
content_catalog
Product content catalog.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
content_type |
text | no | — | unique |
payload |
jsonb | no | — | |
active |
boolean | no | true | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
documents
Polymorphic document records with a file attachment, scoped to organization/campus.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
entity_type |
enum | yes | — | |
entity_reference |
text | yes | — | |
name |
text | yes | — | |
category |
enum | yes | — | |
uploaded_at |
timestamptz | yes | — | |
notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
campusId |
uuid | yes | — | FK |
organizationId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - has many
fileasfile(FKbelongsToId)
frame_entries
Product-module "frame" entries.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
week_of |
text | no | — | |
posted_date |
text | no | — | |
formal |
text | no | — | |
recognition |
text | no | — | |
application |
text | no | — | |
management |
text | no | — | |
emotional |
text | no | — | |
author |
text | no | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId)
user_progress
Per-user progress (sign learning, zone check-ins).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
progress_type |
text | no | — | |
item_id |
text | no | — | |
value |
text | yes | — | |
score |
integer | yes | — | |
metadata |
jsonb | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
userId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersasuser(FKuserId)
safety_quiz_results
Product-module safety quiz results.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
quiz_id |
text | no | — | |
quiz_title |
text | no | — | |
week_of |
text | no | — | |
score |
integer | no | — | |
total_questions |
integer | no | — | |
answers |
jsonb | no | — | |
user_name |
text | no | — | |
user_role |
text | no | — | |
completed_at |
timestamptz | no | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
userId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersasuser(FKuserId)
walkthrough_checkins
Product-module walkthrough check-ins.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
teacher_name |
text | no | — | |
classroom |
text | no | — | |
director_name |
text | no | — | |
check_in_date |
date | no | — | |
check_in_time |
time | no | — | |
attitude_rating |
integer | no | — | |
attitude_comment |
text | yes | — | |
classroom_management_rating |
integer | no | — | |
classroom_management_comment |
text | yes | — | |
cleanliness_rating |
integer | no | — | |
cleanliness_comment |
text | yes | — | |
vibes_rating |
integer | no | — | |
vibes_comment |
text | yes | — | |
team_dynamics_rating |
integer | no | — | |
team_dynamics_comment |
text | yes | — | |
emergency_exit_rating |
integer | no | — | |
emergency_exit_comment |
text | yes | — | |
lesson_plan_rating |
integer | no | — | |
lesson_plan_comment |
text | yes | — | |
overall_notes |
text | yes | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId)
personality_quiz_results
Product-module personality quiz results.
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
personality_type |
text | no | — | |
quiz_answers |
jsonb | no | — | |
completed_at |
timestamptz | no | — | |
importHash |
varchar | yes | — | unique, audit |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
organizationId |
uuid | yes | — | FK |
campusId |
uuid | yes | — | FK |
userId |
uuid | yes | — | FK |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
Relations:
- belongs to
organizationsasorganization(FKorganizationId) - belongs to
campusesascampus(FKcampusId) - belongs to
usersasuser(FKuserId)
System
file
Polymorphic file/attachment store (belongsTo + belongsToColumn + belongsToId).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
belongsTo |
varchar | yes | — | |
belongsToId |
uuid | yes | — | FK |
belongsToColumn |
varchar | yes | — | |
name |
varchar | no | — | |
sizeInBytes |
integer | yes | — | |
privateUrl |
varchar | yes | — | |
publicUrl |
varchar | no | — | |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
deletedAt |
timestamptz | yes | — | audit |
createdById |
uuid | yes | — | FK, audit |
updatedById |
uuid | yes | — | FK, audit |
auth_refresh_tokens
Refresh-token rotation records for cookie-based auth (hash, family, expiry, revocation).
| Column | Type | Null | Default | Notes |
|---|---|---|---|---|
id |
uuid | no | UUIDV4 | PK |
userId |
uuid | no | — | FK |
organizationId |
uuid | yes | — | FK |
tokenHash |
text | no | — | unique |
familyId |
uuid | no | — | FK |
previousTokenId |
uuid | yes | — | FK |
userAgent |
text | yes | — | |
ipAddress |
text | yes | — | |
expiresAt |
timestamptz | no | — | |
revokedAt |
timestamptz | yes | — | |
replacedByTokenId |
uuid | yes | — | FK |
createdAt |
timestamptz | yes | — | audit |
updatedAt |
timestamptz | yes | — | audit |
Relations:
- belongs to
usersasuser(FKuserId) - belongs to
organizationsasorganization(FKorganizationId)