1 parent
cfc74d9db6
commit
dacdf9c27d
76 files changed
+5209
-741
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# Database schemas and migrations
|
||||
|
||||
RustBox 0.2.6 keeps SQL, blob storage and search as independent concerns:
|
||||
RustBox 0.2.8 keeps SQL, blob storage and search as independent concerns:
|
||||
|
||||
```text
|
||||
database_backend = sqlite | mysql | pgsql
|
||||
@@ -17,16 +17,19 @@ When `session_backend = "database"`, sessions live in the selected SQL database.
|
||||
migrations/
|
||||
├── sqlite/
|
||||
│ ├── schema.sql
|
||||
│ └── V047__blob_keys_and_search_outbox.sql
|
||||
│ ├── V047__blob_keys_and_search_outbox.sql
|
||||
│ └── V048__folder_counter_generation.sql
|
||||
├── mysql/
|
||||
│ ├── schema.sql
|
||||
│ └── V047__blob_keys_and_search_outbox.sql
|
||||
│ ├── V047__blob_keys_and_search_outbox.sql
|
||||
│ └── V048__folder_counter_generation.sql
|
||||
└── pgsql/
|
||||
├── schema.sql
|
||||
└── V047__blob_keys_and_search_outbox.sql
|
||||
├── V047__blob_keys_and_search_outbox.sql
|
||||
└── V048__folder_counter_generation.sql
|
||||
```
|
||||
|
||||
Each `schema.sql` is the current complete schema for fresh installations. The historical compatibility baseline remains **V046**. RustBox 0.2.1 adds **V047**, which adds attachment SHA-256 metadata and the durable search outbox used by external indexing.
|
||||
Each `schema.sql` is the current complete schema for fresh installations. The historical compatibility baseline remains **V046**. RustBox 0.2.1 adds **V047**, which adds attachment SHA-256 metadata and the durable search outbox used by external indexing. RustBox 0.2.8 adds **V048**, which adds the monotonic `folders.counter_generation` used to reject stale IMAP counter writes even when the numeric counts temporarily return to an earlier value.
|
||||
|
||||
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/migration time. Sessions are global and therefore are not prefixed.
|
||||
|
||||
@@ -34,7 +37,7 @@ Account data is isolated inside the selected physical database with a determinis
|
||||
|
||||
Every schema-changing release must add the same logical migration for all supported SQL engines and register it in `src/db/pool.rs`. Do not update only `schema.sql`: fresh installs use the baseline while existing installations use the numbered migration path.
|
||||
|
||||
The next migration number after RustBox 0.2.6 is **V048**.
|
||||
The next migration number after RustBox 0.2.8 is **V049**.
|
||||
|
||||
Redis and Redis Sentinel do not use SQL migrations.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE {{p}}folders ADD COLUMN counter_generation BIGINT NOT NULL DEFAULT 0;
|
||||
@@ -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: V046. Current runtime schema: V047.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V048.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -247,6 +247,7 @@ CREATE TABLE {{p}}folders (
|
||||
unread_count BIGINT NOT NULL DEFAULT 0,
|
||||
uid_validity BIGINT NOT NULL DEFAULT 0,
|
||||
highest_modseq BIGINT NOT NULL DEFAULT 0,
|
||||
counter_generation BIGINT NOT NULL DEFAULT 0,
|
||||
updated_at VARCHAR(64) NOT NULL DEFAULT (CAST(CURRENT_TIMESTAMP AS CHAR)),
|
||||
messages_updated_at VARCHAR(64)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE {{p}}folders ADD COLUMN counter_generation BIGINT NOT NULL DEFAULT 0;
|
||||
@@ -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: V046. Current runtime schema: V047.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V048.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -248,6 +248,7 @@ CREATE TABLE {{p}}folders (
|
||||
unread_count BIGINT NOT NULL DEFAULT 0,
|
||||
uid_validity BIGINT NOT NULL DEFAULT 0,
|
||||
highest_modseq BIGINT NOT NULL DEFAULT 0,
|
||||
counter_generation BIGINT NOT NULL DEFAULT 0,
|
||||
updated_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP::text),
|
||||
messages_updated_at TEXT
|
||||
);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE {{p}}folders ADD COLUMN counter_generation INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -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: V046. Current runtime schema: V047.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V048.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -184,6 +184,7 @@ CREATE TABLE {{p}}folders (
|
||||
unread_count INTEGER NOT NULL DEFAULT 0,
|
||||
uid_validity INTEGER NOT NULL DEFAULT 0,
|
||||
highest_modseq INTEGER NOT NULL DEFAULT 0,
|
||||
counter_generation INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
messages_updated_at TEXT);
|
||||
|
||||
|
||||
Reference in new issue
Block a user