Skip to content

Files

files

  • Schema: public
  • PK: file_id (uuid, gen_random_uuid())

Columns

Column Type Nullable Default Notes
file_id uuid NO gen_random_uuid() PK
workspace_id bigint NO FK to workspaces
storage_provider_app_type enum storage_provider YES 's3' Storage backend type
connection_id uuid YES FK to connections (external storage)
file_id_in_external_storage text NO Key/path in the storage backend
storage_region text YES AWS region or equivalent
name text NO Original filename
mime_type text NO MIME type
size_bytes bigint NO File size
tags text[] YES {} Searchable tags
source text YES Origin resource type
source_ref text YES Origin resource ID
created_at timestamptz YES now()
created_by bigint YES FK to users
updated_at timestamptz YES now()
derived_from_file_id uuid YES FK to files (parent/source file)
deleted_at timestamptz YES Soft-delete timestamp

Key indexes

  • files_pkey on (file_id)
  • idx_files_workspace_created on (workspace_id, created_at)
  • idx_files_derived on (derived_from_file_id)
  • idx_files_tags GIN on (tags)
  • idx_files_source on (source, source_ref)

Notes

  • Soft-deleted via deleted_at IS NOT NULL.
  • Supports derived files (e.g. thumbnails, conversions) via derived_from_file_id.