Skip to content

Document data model

Table: documents

Key fields

Field Type Notes
id bigint Primary key
user_id foreign key Owner
type string (enum) Document type (CV, cover letter, other)
original_name string Uploaded filename
custom_name string (nullable) User-defined name
path string Storage path
mime_type string File type
size integer File size in bytes
created_at timestamp
updated_at timestamp
deleted_at timestamp Soft delete

Pivot table: application_document

Field Type Notes
id bigint Primary key
application_id foreign key Related application
document_id foreign key Related document
created_at timestamp

Unique constraint on (application_id, document_id).


Relationships

  • belongs to User
  • belongs to many Applications (through pivot)

Design considerations

Documents:

  • exist independently from applications
  • may be reused across multiple applications
  • remain accessible for historical reference

Soft deletes preserve traceability.