Use sql migration over direct tables.sql modification

This commit is contained in:
jikstra
2022-12-01 15:11:35 +01:00
parent d5faf75f56
commit 41a87a0626
2 changed files with 12 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ use crate::provider::get_provider_by_domain;
use crate::sql::Sql; use crate::sql::Sql;
use crate::tools::EmailAddress; use crate::tools::EmailAddress;
const DBVERSION: i32 = 68; const DBVERSION: i32 = 69;
const VERSION_CFG: &str = "dbversion"; const VERSION_CFG: &str = "dbversion";
const TABLES: &str = include_str!("./tables.sql"); const TABLES: &str = include_str!("./tables.sql");
@@ -616,6 +616,15 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
) )
.await?; .await?;
} }
if dbversion < 94 {
sql.execute_migration(
r#"
ALTER TABLE chats ADD COLUMN encryption_modus INTEGER DEFAULT 0;
ALTER TABLE msgs ADD COLUMN encryption_modus INTEGER DEFAULT 0;"#,
94,
)
.await?;
}
let new_version = sql let new_version = sql
.get_raw_config_int(VERSION_CFG) .get_raw_config_int(VERSION_CFG)

View File

@@ -38,8 +38,7 @@ CREATE TABLE chats (
locations_last_sent INTEGER DEFAULT 0, locations_last_sent INTEGER DEFAULT 0,
created_timestamp INTEGER DEFAULT 0, created_timestamp INTEGER DEFAULT 0,
muted_until INTEGER DEFAULT 0, muted_until INTEGER DEFAULT 0,
ephemeral_timer INTEGER, ephemeral_timer INTEGER
encryption_modus INTEGER DEFAULT 0
); );
CREATE INDEX chats_index1 ON chats (grpid); CREATE INDEX chats_index1 ON chats (grpid);
CREATE INDEX chats_index2 ON chats (archived); CREATE INDEX chats_index2 ON chats (archived);
@@ -93,8 +92,7 @@ CREATE TABLE msgs (
-- deleted. It is convenient to store it here because UI -- deleted. It is convenient to store it here because UI
-- needs this value to display how much time is left until -- needs this value to display how much time is left until
-- the message is deleted. -- the message is deleted.
ephemeral_timestamp INTEGER DEFAULT 0, ephemeral_timestamp INTEGER DEFAULT 0
encryption_modus INTEGER DEFAULT 0
); );
CREATE INDEX msgs_index1 ON msgs (rfc724_mid); CREATE INDEX msgs_index1 ON msgs (rfc724_mid);