Skip to main content

Data Model

The MakerLab domain data is stored in a PostgreSQL 16 database. The schema is applied automatically on first container start via infra/db/init/schema.sql.

Snipe-IT uses a separate MariaDB database managed internally. The MakerLab application does not access the MariaDB database directly.


Entity Relationship Diagram​


Table reference​

users​

Stores all registered users. Created automatically on first SSO login.

ColumnTypeNotes
idBIGSERIAL PK
nameVARCHAR(150)Full name from SSO
emailVARCHAR(255) UNIQUEUniversity email
roleVARCHAR(50)student, professor, or lab_technician
nmecVARCHAR(50)Student number (optional)
courseVARCHAR(200)Course name (optional)
academic_yearVARCHAR(20)Academic year (optional)
legacy_idBIGINT UNIQUELegacy wiki user ID
created_atTIMESTAMP

CHECK: role IN ('student', 'professor', 'lab_technician')


projects​

A project is created by a user and can have multiple members.

ColumnTypeNotes
idBIGSERIAL PK
nameVARCHAR(200)
descriptionTEXT
courseVARCHAR(100)
academic_yearVARCHAR(20)
group_numberINTEGER
created_byBIGINT FK → users
statusVARCHAR(50)See status values
tagsTEXTComma-separated or JSON
linksTEXTRelated URLs
approved_atTIMESTAMP
legacy_idBIGINT UNIQUELegacy wiki project ID
created_atTIMESTAMP

CHECK: status IN ('pending', 'active', 'rejected', 'completed', 'archived')


project_members​

Junction table linking users to projects with a role.

CHECK: role IN ('leader', 'member', 'observer', 'advisor', 'supervisor')
UNIQUE: (project_id, user_id)


equipment_models​

Represents a type or model of equipment (e.g., "Arduino Uno"). Synced from Snipe-IT models.

ColumnNotes
snipeit_model_idReference to Snipe-IT model ID
legacy_idLegacy wiki article ID
legacy_reference_codeOriginal wiki Código value

equipment​

Represents a single physical asset instance. Maps to a Snipe-IT asset.

ColumnNotes
model_idFK → equipment_models
snipeit_asset_idReference to Snipe-IT asset ID
statusavailable, reserved, checked_out, maintenance, retired
conditionnew, good, fair, damaged, unusable
legacy_idLegacy wiki article ID

equipment_request​

A requisition by a student for a specific physical asset.

ColumnNotes
snipeit_asset_idSnipe-IT asset being requested
statuspending, reserved, rejected, checked_out, returned
rejection_reasonSet when rejected
approved_atTimestamp of approval
checked_out_atDetected from Snipe-IT activity
returned_atDetected from Snipe-IT activity
expected_checkinOptional due date

equipment_request_items​

Links a requisition to specific equipment records. Supports multi-item requisitions.


equipment_usage​

Records actual usage of equipment: checkout time, return time, and snapshot of asset metadata at time of use.

CHECK: status IN ('checked_out', 'returned', 'overdue', 'lost')


status_history​

Immutable audit log of all status transitions for projects, equipment requests, and equipment.

CHECK: entity_type IN ('project', 'equipment_request', 'equipment_usage', 'equipment')


notifications​

User-specific notifications generated on key events (approval, rejection, checkout, return).

CHECK: type IN ('info', 'warning', 'request', 'approval', 'return', 'reminder')


Schema file location​

infra/db/init/schema.sql

This file is mounted as docker-entrypoint-initdb.d/schema.sql in the PostgreSQL container and applied automatically on first start.

To reset the schema:

docker compose -f infra/docker/docker-compose.yml down -v
docker compose -f infra/docker/docker-compose.yml up -d
warning

Running down -v destroys all data in the PostgreSQL volume. Only do this in development.