feat: pre-messages / next version of download on demand (#7371)

Closes <https://github.com/chatmail/core/issues/7367>

Co-authored-by: iequidoo <dgreshilov@gmail.com>
Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
Simon Laux
2026-01-08 22:14:32 +00:00
committed by GitHub
parent 46bbe5f077
commit 2631745a57
43 changed files with 2843 additions and 1393 deletions

View File

@@ -1499,6 +1499,32 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
.await?;
}
inc_and_check(&mut migration_version, 145)?;
if dbversion < migration_version {
// `msg_id` in `download` table is not needed anymore,
// but we still keep it so that it's possible to import a backup into an older DC version,
// because we don't always release at the same time on all platforms.
sql.execute_migration(
"CREATE TABLE download_new (
rfc724_mid TEXT PRIMARY KEY,
msg_id INTEGER NOT NULL DEFAULT 0
) STRICT;
INSERT OR IGNORE INTO download_new (rfc724_mid, msg_id)
SELECT m.rfc724_mid, d.msg_id FROM download d
LEFT JOIN msgs m ON d.msg_id = m.id
WHERE m.rfc724_mid IS NOT NULL AND m.rfc724_mid != '';
DROP TABLE download;
ALTER TABLE download_new RENAME TO download;
CREATE TABLE available_post_msgs (
rfc724_mid TEXT PRIMARY KEY
) STRICT;
ALTER TABLE msgs ADD COLUMN pre_rfc724_mid TEXT DEFAULT '';
CREATE INDEX msgs_index9 ON msgs (pre_rfc724_mid);",
migration_version,
)
.await?;
}
let new_version = sql
.get_raw_config_int(VERSION_CFG)
.await?