1 parent
83440f20e2
commit
12e0c99850
32 files changed
+729
-109
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# Database schemas and migrations
|
||||
|
||||
RustBox 0.2.12 keeps SQL, blob storage and search as independent concerns:
|
||||
RustBox 0.2.13 keeps SQL, blob storage and search as independent concerns:
|
||||
|
||||
```text
|
||||
database_backend = sqlite | mysql | pgsql
|
||||
@@ -18,18 +18,21 @@ migrations/
|
||||
├── sqlite/
|
||||
│ ├── schema.sql
|
||||
│ ├── V047__blob_keys_and_search_outbox.sql
|
||||
│ └── V048__folder_counter_generation.sql
|
||||
│ ├── V048__folder_counter_generation.sql
|
||||
│ └── V049__blob_delete_outbox.sql
|
||||
├── mysql/
|
||||
│ ├── schema.sql
|
||||
│ ├── V047__blob_keys_and_search_outbox.sql
|
||||
│ └── V048__folder_counter_generation.sql
|
||||
│ ├── V048__folder_counter_generation.sql
|
||||
│ └── V049__blob_delete_outbox.sql
|
||||
└── pgsql/
|
||||
├── schema.sql
|
||||
├── V047__blob_keys_and_search_outbox.sql
|
||||
└── V048__folder_counter_generation.sql
|
||||
├── V048__folder_counter_generation.sql
|
||||
└── V049__blob_delete_outbox.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. 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.
|
||||
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. RustBox 0.2.13 adds **V049**, the durable `blob_delete_outbox` used to retry physical object deletion after metadata is removed.
|
||||
|
||||
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.
|
||||
|
||||
@@ -37,7 +40,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.
|
||||
|
||||
RustBox 0.2.12 does not add a runtime schema migration; **V049** remains the next migration number.
|
||||
RustBox 0.2.13 adds runtime migration **V049** on SQLite, MySQL and PostgreSQL. **V050** is the next migration number.
|
||||
|
||||
Redis and Redis Sentinel do not use SQL migrations.
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts BIGINT NOT NULL DEFAULT 0,
|
||||
available_at BIGINT NOT NULL DEFAULT 0,
|
||||
claimed_until BIGINT NOT NULL DEFAULT 0,
|
||||
last_error TEXT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL,
|
||||
INDEX idx_blob_delete_outbox_ready (available_at, claimed_until, updated_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@@ -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: V048.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V049.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -190,6 +190,19 @@ CREATE TABLE {{p}}draft_attachments (
|
||||
created_at VARCHAR(64) NOT NULL DEFAULT (CAST(CURRENT_TIMESTAMP AS CHAR))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts BIGINT NOT NULL DEFAULT 0,
|
||||
available_at BIGINT NOT NULL DEFAULT 0,
|
||||
claimed_until BIGINT NOT NULL DEFAULT 0,
|
||||
last_error TEXT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL,
|
||||
INDEX idx_blob_delete_outbox_ready (available_at, claimed_until, updated_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE {{p}}search_outbox (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
generation VARCHAR(64) NOT NULL,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts BIGINT NOT NULL DEFAULT 0,
|
||||
available_at BIGINT NOT NULL DEFAULT 0,
|
||||
claimed_until BIGINT NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX {{p}}idx_blob_delete_outbox_ready
|
||||
ON {{p}}blob_delete_outbox(available_at, claimed_until, updated_at);
|
||||
@@ -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: V048.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V049.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -190,6 +190,20 @@ CREATE TABLE {{p}}draft_attachments (
|
||||
created_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP::text)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts BIGINT NOT NULL DEFAULT 0,
|
||||
available_at BIGINT NOT NULL DEFAULT 0,
|
||||
claimed_until BIGINT NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX {{p}}idx_blob_delete_outbox_ready ON {{p}}blob_delete_outbox(available_at, claimed_until, updated_at);
|
||||
|
||||
CREATE TABLE {{p}}search_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
generation TEXT NOT NULL,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts INTEGER NOT NULL DEFAULT 0,
|
||||
available_at INTEGER NOT NULL DEFAULT 0,
|
||||
claimed_until INTEGER NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX {{p}}idx_blob_delete_outbox_ready
|
||||
ON {{p}}blob_delete_outbox(available_at, claimed_until, updated_at);
|
||||
@@ -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: V048.
|
||||
-- Squashed compatibility baseline: V046. Current runtime schema: V049.
|
||||
|
||||
-- RUSTBOX:GLOBAL-BEGIN
|
||||
CREATE TABLE IF NOT EXISTS rustbox_accounts (
|
||||
@@ -136,6 +136,20 @@ CREATE TABLE {{p}}draft_attachments (
|
||||
FOREIGN KEY (draft_id) REFERENCES {{p}}drafts(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE {{p}}blob_delete_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
storage_key TEXT NOT NULL,
|
||||
attempts INTEGER NOT NULL DEFAULT 0,
|
||||
available_at INTEGER NOT NULL DEFAULT 0,
|
||||
claimed_until INTEGER NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX {{p}}idx_blob_delete_outbox_ready ON {{p}}blob_delete_outbox(available_at, claimed_until, updated_at);
|
||||
|
||||
CREATE TABLE {{p}}search_outbox (
|
||||
id TEXT PRIMARY KEY,
|
||||
generation TEXT NOT NULL,
|
||||
|
||||
Reference in new issue
Block a user