Database schema
Each workspace has one SQLite database, altar.db, next to its assets/ and backups/ folders. See Workspace folder.
Connection
- One connection behind a mutex. All access goes through
Workspace::with(|conn| …)indb.rs. - Pragmas:
journal_mode = WAL,foreign_keys = ON,synchronous = NORMAL. - Only one copy of Altar Studio runs at a time (the single-instance plugin), so only one process writes to a workspace.
Migrations
Migrations are SQL strings in the MIGRATIONS array in db.rs, numbered by PRAGMA user_version. There is currently one: v1, the initial schema.
- Pending migrations run in one transaction, setting
user_versionafter each. - Before migrating an existing database, the backend copies it to
backups/pre-migration-v<N>-<timestamp>.dbwithVACUUM INTO. - To change the schema, append a new migration. Never edit an existing one.
Tables
resources
Library content: songs, presentations (prayers, The Word, slides), themes, breakers, lower thirds, feeds and PowerPoint decks.
| Column | Type | Notes |
|---|---|---|
id | TEXT PK | UUID |
kind | TEXT | song, presentation, theme, breaker, lowerthird, feed, deck |
title | TEXT | |
subtitle | TEXT | |
search_text | TEXT | Text indexed for search |
data | TEXT | JSON payload for the kind |
revision | INTEGER | Default 1, bumped on each save |
archived | INTEGER | 0 or 1 (soft delete) |
created_at, updated_at | INTEGER | Epoch ms |
Index resources_kind (kind, archived, title COLLATE NOCASE).
resources_fts
FTS5 index over title and search_text. External content (content='resources'), tokenizer unicode61 remove_diacritics 2, prefix indexes for 2 and 3 characters. The triggers resources_ai, resources_ad and resources_au keep it in sync.
services
| Column | Type | Notes |
|---|---|---|
id | TEXT PK | |
name | TEXT | Required |
service_date | TEXT | Nullable |
notes | TEXT | |
data | TEXT | JSON {items: ScheduleNode[]} |
revision | INTEGER | Bumped on save, not checked |
created_at, updated_at | INTEGER |
assets
| Column | Type | Notes |
|---|---|---|
hash | TEXT PK | SHA-256, hex |
name | TEXT | First name it was imported under |
ext, kind, mime | TEXT | |
size | INTEGER | Bytes |
rel_path | TEXT | assets/<first two hex chars>/<hash>.<ext> |
meta | TEXT | JSON, default {} |
archived | INTEGER | |
created_at | INTEGER |
bible_packs
id (PK), name, abbreviation, language, version, rights (JSON), structure (JSON: books and verse counts per chapter), installed_at.
verses
Primary key (translation_id, book, chapter, verse), plus text. translation_id references bible_packs(id) with ON DELETE CASCADE. WITHOUT ROWID.
verses_fts_map and verses_fts
verses_fts is a standalone FTS5 table over verse text (unicode61 remove_diacritics 2). verses_fts_map maps each FTS row ID back to (translation_id, book, chapter, verse), with an index on translation_id.
settings
key (TEXT PK), value (TEXT, JSON).
| Key | Contents |
|---|---|
app | AppSettings: everything on the Settings page, including the church profile |
firstRunComplete | true after the first-run wizard |
lastServiceId | The service to reopen at launch |
sampleInstalled | Whether sample content was installed |
scripture-history | Up to 200 passages sent live |
history
The presentation log: id (autoincrement), at, service_id, command, scene_revision, result. It's trimmed to about the newest 20 000 rows.
Commands written: go-live, go-live:transition (result queued), transition-complete, mode:content, mode:black, mode:logo.
Search queries
library::fts_query splits the query on characters that aren't letters or digits (apostrophes are kept), quotes each word, adds * for prefix matching, and joins them, so every word must match. bible_search uses the same function.