# Data model

> The sypnia_files schema: buckets, objects, uploads in progress, S3 keys and the functions policies use.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://files.docs.sypnia.com/architecture/data-model/

For agents: Files data model: sypnia_files.buckets (public, max_file_size, allowed_types, scan, cache_control, storage backend+prefix), objects (bucket_id, name, owner, size, content_type, checksum, scan_status not_scanned|pending|clean|infected, metadata, case; unique bucket+name; RLS on), uploads (resumable in progress), s3_keys (secret_hash, buckets, actions), audit; functions foldername/filename/extension; installed by sypnia-files install; storage key <project>/<bucket>/<object id> so moves only update rows.

| Table                  | Holds                                                                                                                                                                                                                                                                                                                  |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sypnia_files.buckets` | `id`, `public`, `max_file_size`, `allowed_types`, `scan`, `cache_control`, `storage` (the backend and prefix), `created_at`                                                                                                                                                                                            |
| `sypnia_files.objects` | `id`, `bucket_id`, `name`, `owner`, `size`, `content_type`, `checksum`, `scan_status` (`not_scanned`, `pending`, `clean`, `infected`), `metadata`, `case` (the [use case](https://files.docs.sypnia.com/buckets/use-cases) that last wrote it), timestamps; unique on (`bucket_id`, `name`); **row-level security on** |
| `sypnia_files.uploads` | resumable uploads in progress: `id`, `bucket_id`, `name`, `owner`, `offset`, `size`, `expires_at`, the storage upload id                                                                                                                                                                                               |
| `sypnia_files.s3_keys` | `id`, `secret_hash`, `buckets`, `actions`, `created_by`, `last_used_at`                                                                                                                                                                                                                                                |
| `sypnia_files.audit`   | key and admin actions                                                                                                                                                                                                                                                                                                  |

Functions: `sypnia_files.foldername(text) returns text[]`, `filename(text)`, `extension(text)`. The schema is installed by the engine's migrations (`sypnia-files install`) and never edited by hand.

In storage, an object lives at `<project>/<bucket>/<object id>`, not at its path: moving a file only updates its row.
