1 parent
d55640d37a
commit
fff8521a17
67 files changed
+11016
-16763
No files matched your search
+161
-42
@@ -35,46 +35,164 @@ impl UserDb {
|
||||
/// All migration scripts in order. Each entry is (version, sql).
|
||||
const MIGRATIONS: &[(u32, &str)] = &[
|
||||
(1, include_str!("../../migrations/V001__initial_schema.sql")),
|
||||
(2, include_str!("../../migrations/V002__folders_and_messages.sql")),
|
||||
(
|
||||
2,
|
||||
include_str!("../../migrations/V002__folders_and_messages.sql"),
|
||||
),
|
||||
(3, include_str!("../../migrations/V003__add_date_epoch.sql")),
|
||||
(4, include_str!("../../migrations/V004__folder_messages_updated_at.sql")),
|
||||
(5, include_str!("../../migrations/V005__drafts_and_attachments.sql")),
|
||||
(6, include_str!("../../migrations/V006__cache_attachments_and_headers.sql")),
|
||||
(
|
||||
4,
|
||||
include_str!("../../migrations/V004__folder_messages_updated_at.sql"),
|
||||
),
|
||||
(
|
||||
5,
|
||||
include_str!("../../migrations/V005__drafts_and_attachments.sql"),
|
||||
),
|
||||
(
|
||||
6,
|
||||
include_str!("../../migrations/V006__cache_attachments_and_headers.sql"),
|
||||
),
|
||||
(7, include_str!("../../migrations/V007__contacts.sql")),
|
||||
(8, include_str!("../../migrations/V008__identities.sql")),
|
||||
(9, include_str!("../../migrations/V009__notification_preferences.sql")),
|
||||
(10, include_str!("../../migrations/V010__contact_groups.sql")),
|
||||
(11, include_str!("../../migrations/V011__message_reaction.sql")),
|
||||
(
|
||||
9,
|
||||
include_str!("../../migrations/V009__notification_preferences.sql"),
|
||||
),
|
||||
(
|
||||
10,
|
||||
include_str!("../../migrations/V010__contact_groups.sql"),
|
||||
),
|
||||
(
|
||||
11,
|
||||
include_str!("../../migrations/V011__message_reaction.sql"),
|
||||
),
|
||||
(12, include_str!("../../migrations/V012__tags.sql")),
|
||||
(13, include_str!("../../migrations/V013__display_preferences.sql")),
|
||||
(14, include_str!("../../migrations/V014__compose_format.sql")),
|
||||
(
|
||||
13,
|
||||
include_str!("../../migrations/V013__display_preferences.sql"),
|
||||
),
|
||||
(
|
||||
14,
|
||||
include_str!("../../migrations/V014__compose_format.sql"),
|
||||
),
|
||||
(15, include_str!("../../migrations/V015__deep_index.sql")),
|
||||
(16, include_str!("../../migrations/V016__calendar.sql")),
|
||||
(17, include_str!("../../migrations/V017__add_email_theme.sql")),
|
||||
(18, include_str!("../../migrations/V018__animation_mode.sql")),
|
||||
(19, include_str!("../../migrations/V019__known_addresses.sql")),
|
||||
(20, include_str!("../../migrations/V020__appearance_personalization.sql")),
|
||||
(21, include_str!("../../migrations/V021__special_folders.sql")),
|
||||
(22, include_str!("../../migrations/V022__identity_options.sql")),
|
||||
(23, include_str!("../../migrations/V023__saved_searches.sql")),
|
||||
(24, include_str!("../../migrations/V024__notification_dnd.sql")),
|
||||
(25, include_str!("../../migrations/V025__custom_theme_colors.sql")),
|
||||
(26, include_str!("../../migrations/V026__mail_preferences.sql")),
|
||||
(27, include_str!("../../migrations/V027__contact_profile.sql")),
|
||||
(28, include_str!("../../migrations/V028__contact_multi_values.sql")),
|
||||
(29, include_str!("../../migrations/V029__draft_send_options.sql")),
|
||||
(30, include_str!("../../migrations/V030__folder_list_preferences.sql")),
|
||||
(31, include_str!("../../migrations/V031__compose_preferences.sql")),
|
||||
(32, include_str!("../../migrations/V032__advanced_appearance.sql")),
|
||||
(33, include_str!("../../migrations/V033__draft_compose_format.sql")),
|
||||
(34, include_str!("../../migrations/V034__imap_keyword_sync.sql")),
|
||||
(35, include_str!("../../migrations/V035__compose_behavior_preferences.sql")),
|
||||
(36, include_str!("../../migrations/V036__remote_draft_tracking.sql")),
|
||||
(37, include_str!("../../migrations/V037__openpgp_keyring.sql")),
|
||||
(38, include_str!("../../migrations/V038__identity_openpgp.sql")),
|
||||
(39, include_str!("../../migrations/V039__draft_openpgp_options.sql")),
|
||||
(40, include_str!("../../migrations/V040__draft_openpgp_attach_key.sql")),
|
||||
(41, include_str!("../../migrations/V041__draft_openpgp_recipient_keys.sql")),
|
||||
(
|
||||
17,
|
||||
include_str!("../../migrations/V017__add_email_theme.sql"),
|
||||
),
|
||||
(
|
||||
18,
|
||||
include_str!("../../migrations/V018__animation_mode.sql"),
|
||||
),
|
||||
(
|
||||
19,
|
||||
include_str!("../../migrations/V019__known_addresses.sql"),
|
||||
),
|
||||
(
|
||||
20,
|
||||
include_str!("../../migrations/V020__appearance_personalization.sql"),
|
||||
),
|
||||
(
|
||||
21,
|
||||
include_str!("../../migrations/V021__special_folders.sql"),
|
||||
),
|
||||
(
|
||||
22,
|
||||
include_str!("../../migrations/V022__identity_options.sql"),
|
||||
),
|
||||
(
|
||||
23,
|
||||
include_str!("../../migrations/V023__saved_searches.sql"),
|
||||
),
|
||||
(
|
||||
24,
|
||||
include_str!("../../migrations/V024__notification_dnd.sql"),
|
||||
),
|
||||
(
|
||||
25,
|
||||
include_str!("../../migrations/V025__custom_theme_colors.sql"),
|
||||
),
|
||||
(
|
||||
26,
|
||||
include_str!("../../migrations/V026__mail_preferences.sql"),
|
||||
),
|
||||
(
|
||||
27,
|
||||
include_str!("../../migrations/V027__contact_profile.sql"),
|
||||
),
|
||||
(
|
||||
28,
|
||||
include_str!("../../migrations/V028__contact_multi_values.sql"),
|
||||
),
|
||||
(
|
||||
29,
|
||||
include_str!("../../migrations/V029__draft_send_options.sql"),
|
||||
),
|
||||
(
|
||||
30,
|
||||
include_str!("../../migrations/V030__folder_list_preferences.sql"),
|
||||
),
|
||||
(
|
||||
31,
|
||||
include_str!("../../migrations/V031__compose_preferences.sql"),
|
||||
),
|
||||
(
|
||||
32,
|
||||
include_str!("../../migrations/V032__advanced_appearance.sql"),
|
||||
),
|
||||
(
|
||||
33,
|
||||
include_str!("../../migrations/V033__draft_compose_format.sql"),
|
||||
),
|
||||
(
|
||||
34,
|
||||
include_str!("../../migrations/V034__imap_keyword_sync.sql"),
|
||||
),
|
||||
(
|
||||
35,
|
||||
include_str!("../../migrations/V035__compose_behavior_preferences.sql"),
|
||||
),
|
||||
(
|
||||
36,
|
||||
include_str!("../../migrations/V036__remote_draft_tracking.sql"),
|
||||
),
|
||||
(
|
||||
37,
|
||||
include_str!("../../migrations/V037__openpgp_keyring.sql"),
|
||||
),
|
||||
(
|
||||
38,
|
||||
include_str!("../../migrations/V038__identity_openpgp.sql"),
|
||||
),
|
||||
(
|
||||
39,
|
||||
include_str!("../../migrations/V039__draft_openpgp_options.sql"),
|
||||
),
|
||||
(
|
||||
40,
|
||||
include_str!("../../migrations/V040__draft_openpgp_attach_key.sql"),
|
||||
),
|
||||
(
|
||||
41,
|
||||
include_str!("../../migrations/V041__draft_openpgp_recipient_keys.sql"),
|
||||
),
|
||||
(
|
||||
42,
|
||||
include_str!("../../migrations/V042__trusted_senders.sql"),
|
||||
),
|
||||
(
|
||||
43,
|
||||
include_str!("../../migrations/V043__response_templates.sql"),
|
||||
),
|
||||
(
|
||||
44,
|
||||
include_str!("../../migrations/V044__interface_skin.sql"),
|
||||
),
|
||||
(
|
||||
45,
|
||||
include_str!("../../migrations/V045__response_template_format.sql"),
|
||||
),
|
||||
];
|
||||
|
||||
/// Run any pending migrations based on SQLite's `user_version` PRAGMA.
|
||||
@@ -128,8 +246,7 @@ pub fn open_user_db(data_dir: &str, user_hash: &str) -> Result<Connection, Strin
|
||||
fs::create_dir_all(&dir).map_err(|e| format!("Failed to create db dir: {e}"))?;
|
||||
|
||||
let db_path = dir.join("db.sqlite");
|
||||
let conn =
|
||||
Connection::open(&db_path).map_err(|e| format!("Failed to open SQLite: {e}"))?;
|
||||
let conn = Connection::open(&db_path).map_err(|e| format!("Failed to open SQLite: {e}"))?;
|
||||
|
||||
// Enable WAL mode for better concurrent read performance.
|
||||
conn.execute_batch("PRAGMA journal_mode=WAL;")
|
||||
@@ -216,12 +333,14 @@ mod async_tests {
|
||||
let (started, ready) = tokio::sync::oneshot::channel();
|
||||
let (release, wait) = std::sync::mpsc::channel();
|
||||
let job = tokio::spawn(async move {
|
||||
database.run(move |_| {
|
||||
started.send(()).unwrap();
|
||||
wait.recv_timeout(std::time::Duration::from_secs(2))
|
||||
.map_err(|e| format!("runtime could not release database job: {e}"))?;
|
||||
Ok(())
|
||||
}).await
|
||||
database
|
||||
.run(move |_| {
|
||||
started.send(()).unwrap();
|
||||
wait.recv_timeout(std::time::Duration::from_secs(2))
|
||||
.map_err(|e| format!("runtime could not release database job: {e}"))?;
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
});
|
||||
ready.await.unwrap();
|
||||
// On a current-thread runtime, an inline DB job prevents this send.
|
||||
|
||||
Reference in new issue
Block a user