Model Definition
Generated Schema
This Rust struct will generate the following SQL table:Linking to Core Systems
Extension models are not isolated silos. They are deeply integrated with Spacedrive’s core systems.-
Tagging and Collections: By adding the
#[metadata]attribute to a field, your model is linked to theuser_metadatatable. This allows your custom data models to be tagged, added to collections, and searched just like any other file in Spacedrive. -
Core Entities: You can define foreign key relationships to core Spacedrive tables like
entriesorcontent_identities. This allows you to, for example, create anAlbummodel that has a many-to-many relationship with photos (entries).
Migrations
As you develop your extension, you will inevitably need to change your data models. The Spacedrive SDK includes a migration system to manage schema changes.- Migration Files: You can provide SQL migration files with your extension (e.g.,
v1.1.0_add_birthdate.sql). - Automatic Execution: When a user updates your extension, Spacedrive will automatically run the necessary migrations to bring their database schema up to date.
Extension Locations
Extensions that create files must declare their storage locations. Users choose where the data goes during installation.What to Store Where
Database tables: Domain models, configuration, relationships- EmailAccount, Transaction, Contact
- NOT file metadata (use core entries table)
- .eml files, receipt PDFs, research papers
- User chooses where these go
- Spacedrive indexes automatically
- OCR text, embeddings, extracted metadata
- Stored in library’s sidecar directory
- Portable with your library
