1 parent
d91212d24c
commit
dbe7103687
21 files changed
+182
-154
No files matched your search
+22
-29
@@ -1,42 +1,35 @@
|
||||
# Database schemas and migrations
|
||||
# RustBox database schema and migrations
|
||||
|
||||
RustBox keeps SQL, blob storage and search as independent concerns.
|
||||
RustBox keeps one complete fresh-install schema per supported SQL backend:
|
||||
|
||||
```text
|
||||
database_backend = sqlite | mysql | pgsql
|
||||
session_backend = database | redis
|
||||
storage.backend = filesystem | s3
|
||||
search.backend = disabled | local_tantivy | opensearch
|
||||
```
|
||||
- `sqlite/schema.sql`
|
||||
- `mysql/schema.sql`
|
||||
- `pgsql/schema.sql`
|
||||
|
||||
## Layout
|
||||
## Compatibility baseline
|
||||
|
||||
```text
|
||||
migrations/
|
||||
├── sqlite/schema.sql
|
||||
├── mysql/schema.sql
|
||||
└── pgsql/schema.sql
|
||||
```
|
||||
The consolidated compatibility baseline is **V050**. Historical migrations V047-V050 are already represented by the complete `schema.sql` files and are intentionally not shipped as standalone runtime migrations in this source tree.
|
||||
|
||||
Each `schema.sql` is the complete V050 schema for fresh installations. Migrations V047-V049 have been consolidated into the **V049 compatibility baseline** and their standalone files are intentionally removed. V050 remains the single runtime migration. Because RustBox 0.2.15 has not been released yet, V050 includes `mail_preferences.compact_wide_rows`, `identities.signature_insert_mode`, `display_preferences.adaptive_email_colors` and `mail_preferences.message_loading_mode`.
|
||||
Databases older than V050 must first be upgraded with a RustBox release that can reach V050. RustBox 0.2.16 accepts V050 databases and migrates them forward normally.
|
||||
|
||||
`mail_preferences.message_loading_mode` defaults to `pagination`; `messages_per_page` defaults to 300. Supported modes are `pagination`, `progressive` and `all`.
|
||||
## V051 — RustBox 0.2.16
|
||||
|
||||
Databases older than **V049** are no longer migrated directly by this build. Upgrade them to schema V049 first; this build then applies V050. **V051** is the next migration number after this snapshot.
|
||||
V051 adds the preferences introduced in 0.2.16:
|
||||
|
||||
Account data is isolated inside the selected physical database with a deterministic, collision-checked table prefix derived from the account hash. The `{{p}}` marker in tenant SQL is replaced by RustBox at provisioning time. Sessions are global and therefore are not prefixed.
|
||||
- `display_preferences.adaptive_email_colors`, default `0` / disabled;
|
||||
- `mail_preferences.message_loading_mode`, default `pagination`.
|
||||
|
||||
## Runtime migrations
|
||||
`mail_preferences.messages_per_page` remains `300` by default. Supported message loading modes are `pagination`, `progressive` and `all`.
|
||||
|
||||
V050 is the only runtime migration in this unreleased snapshot. Future schema-changing releases must add the same logical migration for SQLite, MySQL and PostgreSQL and register it in `src/db/pool.rs`.
|
||||
Fresh installations already contain the V051 columns in `schema.sql` and are registered at the latest schema version. Existing V050 tenants execute `V051__adaptive_email_colors_and_message_loading_mode.sql` before application queries use the new columns.
|
||||
|
||||
Redis and Redis Sentinel do not use SQL migrations.
|
||||
The next migration number is **V052**.
|
||||
|
||||
## Engine notes
|
||||
## Migration rules
|
||||
|
||||
- SQLite uses `data_dir/rustbox.sqlite` by default; `database_url` may point to another persistent SQLite file.
|
||||
- MySQL requires `database_url` and targets MySQL 8.0.13 or newer.
|
||||
- PostgreSQL requires `database_url`.
|
||||
- MySQL/PostgreSQL are full application backends, not session-only databases.
|
||||
- The SQL engine does not choose blob/search storage. PostgreSQL/MySQL may still use local filesystem/Tantivy in single-node mode.
|
||||
- Cluster mode requires a shared MySQL/PostgreSQL database plus cluster-safe blob/search choices; local `data_dir` is not inherently required.
|
||||
Any future schema-changing release must:
|
||||
|
||||
1. update all three complete `schema.sql` files;
|
||||
2. add the same logical numbered migration for SQLite, MySQL and PostgreSQL;
|
||||
3. register that migration in `src/db/pool.rs`;
|
||||
4. extend the offline migration tests in `scripts/validate-release-static.py`.
|
||||
-6
@@ -3,9 +3,3 @@ ALTER TABLE {{p}}display_preferences
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN message_loading_mode TEXT NOT NULL DEFAULT 'pagination';
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN compact_wide_rows BIGINT NOT NULL DEFAULT 1;
|
||||
|
||||
ALTER TABLE {{p}}identities
|
||||
ADD COLUMN signature_insert_mode TEXT NOT NULL DEFAULT 'silent';
|
||||
@@ -1,7 +1,7 @@
|
||||
-- RustBox 0.2.0 MySQL schema.
|
||||
-- One physical database contains global sessions plus isolated per-account tables.
|
||||
-- Application tables are materialized by replacing {{p}} with a collision-checked prefix.
|
||||
-- Squashed compatibility baseline: V049. Current schema: V050.
|
||||
-- Squashed compatibility baseline: V050; current schema: V051.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
|
||||
-6
@@ -3,9 +3,3 @@ ALTER TABLE {{p}}display_preferences
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN message_loading_mode TEXT NOT NULL DEFAULT 'pagination';
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN compact_wide_rows BIGINT NOT NULL DEFAULT 1;
|
||||
|
||||
ALTER TABLE {{p}}identities
|
||||
ADD COLUMN signature_insert_mode VARCHAR(16) NOT NULL DEFAULT 'silent';
|
||||
@@ -1,7 +1,7 @@
|
||||
-- RustBox 0.2.0 PostgreSQL schema.
|
||||
-- One physical database contains global sessions plus isolated per-account tables.
|
||||
-- Application tables are materialized by replacing {{p}} with a collision-checked prefix.
|
||||
-- Squashed compatibility baseline: V049. Current schema: V050.
|
||||
-- Squashed compatibility baseline: V050; current schema: V051.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
|
||||
-6
@@ -3,9 +3,3 @@ ALTER TABLE {{p}}display_preferences
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN message_loading_mode TEXT NOT NULL DEFAULT 'pagination';
|
||||
|
||||
ALTER TABLE {{p}}mail_preferences
|
||||
ADD COLUMN compact_wide_rows INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
ALTER TABLE {{p}}identities
|
||||
ADD COLUMN signature_insert_mode TEXT NOT NULL DEFAULT 'silent';
|
||||
@@ -1,7 +1,7 @@
|
||||
-- RustBox 0.2.0 SQLite schema.
|
||||
-- One physical database contains global sessions plus isolated per-account tables.
|
||||
-- Application tables are materialized from the tenant section by replacing {{p}}.
|
||||
-- Squashed compatibility baseline: V049. Current schema: V050.
|
||||
-- Squashed compatibility baseline: V050; current schema: V051.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
|
||||
Reference in new issue
Block a user