1 parent
fb9eab87eb
commit
d91212d24c
40 files changed
+585
-380
No files matched your search
+17
-59
@@ -16,65 +16,23 @@ use tokio::sync::Mutex as AsyncMutex;
|
||||
|
||||
use crate::config::AppConfig;
|
||||
|
||||
pub const BASE_SCHEMA_VERSION: u32 = 46;
|
||||
pub const BASE_SCHEMA_VERSION: u32 = 49;
|
||||
const SQLITE_SCHEMA: &str = include_str!("../../migrations/sqlite/schema.sql");
|
||||
const MYSQL_SCHEMA: &str = include_str!("../../migrations/mysql/schema.sql");
|
||||
const PGSQL_SCHEMA: &str = include_str!("../../migrations/pgsql/schema.sql");
|
||||
|
||||
const SQLITE_MIGRATIONS: &[(u32, &str)] = &[
|
||||
(
|
||||
47,
|
||||
include_str!("../../migrations/sqlite/V047__blob_keys_and_search_outbox.sql"),
|
||||
),
|
||||
(
|
||||
48,
|
||||
include_str!("../../migrations/sqlite/V048__folder_counter_generation.sql"),
|
||||
),
|
||||
(
|
||||
49,
|
||||
include_str!("../../migrations/sqlite/V049__blob_delete_outbox.sql"),
|
||||
),
|
||||
(
|
||||
50,
|
||||
include_str!("../../migrations/sqlite/V050__compact_rows_and_signature_mode.sql"),
|
||||
),
|
||||
];
|
||||
const MYSQL_MIGRATIONS: &[(u32, &str)] = &[
|
||||
(
|
||||
47,
|
||||
include_str!("../../migrations/mysql/V047__blob_keys_and_search_outbox.sql"),
|
||||
),
|
||||
(
|
||||
48,
|
||||
include_str!("../../migrations/mysql/V048__folder_counter_generation.sql"),
|
||||
),
|
||||
(
|
||||
49,
|
||||
include_str!("../../migrations/mysql/V049__blob_delete_outbox.sql"),
|
||||
),
|
||||
(
|
||||
50,
|
||||
include_str!("../../migrations/mysql/V050__compact_rows_and_signature_mode.sql"),
|
||||
),
|
||||
];
|
||||
const PGSQL_MIGRATIONS: &[(u32, &str)] = &[
|
||||
(
|
||||
47,
|
||||
include_str!("../../migrations/pgsql/V047__blob_keys_and_search_outbox.sql"),
|
||||
),
|
||||
(
|
||||
48,
|
||||
include_str!("../../migrations/pgsql/V048__folder_counter_generation.sql"),
|
||||
),
|
||||
(
|
||||
49,
|
||||
include_str!("../../migrations/pgsql/V049__blob_delete_outbox.sql"),
|
||||
),
|
||||
(
|
||||
50,
|
||||
include_str!("../../migrations/pgsql/V050__compact_rows_and_signature_mode.sql"),
|
||||
),
|
||||
];
|
||||
const SQLITE_MIGRATIONS: &[(u32, &str)] = &[(
|
||||
50,
|
||||
include_str!("../../migrations/sqlite/V050__compact_rows_and_signature_mode.sql"),
|
||||
)];
|
||||
const MYSQL_MIGRATIONS: &[(u32, &str)] = &[(
|
||||
50,
|
||||
include_str!("../../migrations/mysql/V050__compact_rows_and_signature_mode.sql"),
|
||||
)];
|
||||
const PGSQL_MIGRATIONS: &[(u32, &str)] = &[(
|
||||
50,
|
||||
include_str!("../../migrations/pgsql/V050__compact_rows_and_signature_mode.sql"),
|
||||
)];
|
||||
|
||||
const TENANT_TABLES: &[&str] = &[
|
||||
"blob_delete_outbox",
|
||||
@@ -1861,7 +1819,7 @@ fn read_legacy_sqlite(path: &Path) -> Result<Vec<LegacyTableData>, String> {
|
||||
.map_err(|e| format!("failed to read legacy SQLite schema version: {e}"))?;
|
||||
if version < BASE_SCHEMA_VERSION {
|
||||
return Err(format!(
|
||||
"legacy SQLite schema version {version} is older than the legacy RustBox baseline {BASE_SCHEMA_VERSION}; upgrade with RustBox 0.1.0 first"
|
||||
"legacy SQLite schema version {version} is older than the consolidated RustBox baseline {BASE_SCHEMA_VERSION}; upgrade to schema V049 first"
|
||||
));
|
||||
}
|
||||
let latest_supported_sqlite = SQLITE_MIGRATIONS
|
||||
@@ -2222,7 +2180,7 @@ fn apply_sqlite_migrations(
|
||||
) -> Result<(), String> {
|
||||
if current < BASE_SCHEMA_VERSION {
|
||||
return Err(format!(
|
||||
"database schema version {current} is older than the legacy RustBox baseline {BASE_SCHEMA_VERSION}; upgrade with RustBox 0.1.0 first"
|
||||
"database schema version {current} is older than the consolidated RustBox baseline {BASE_SCHEMA_VERSION}; upgrade to schema V049 first"
|
||||
));
|
||||
}
|
||||
let latest = latest_schema_version();
|
||||
@@ -2667,7 +2625,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_sqlite_v046_is_imported_and_backed_up() {
|
||||
fn legacy_sqlite_v050_is_imported_and_backed_up() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let data_dir = temp.path();
|
||||
let user_hash = format!("{:x}", Sha256::digest(b"legacy-user"));
|
||||
@@ -2683,7 +2641,7 @@ mod tests {
|
||||
legacy
|
||||
.execute_batch(&tenant_seed_sql(DatabaseBackend::Sqlite, ""))
|
||||
.unwrap();
|
||||
legacy.execute_batch("PRAGMA user_version=46;").unwrap();
|
||||
legacy.execute_batch("PRAGMA user_version=50;").unwrap();
|
||||
legacy.execute(
|
||||
"INSERT INTO display_preferences(id, theme, accent_color) VALUES(1, 'dark', '#123456')",
|
||||
[],
|
||||
|
||||
Reference in new issue
Block a user