Skip to content

Commit

Permalink
fix: recreate smtp table with AUTOINCREMENT
Browse files Browse the repository at this point in the history
This ensures the rows cannot be confused accidentally
when referred by row_id.
  • Loading branch information
link2xt committed May 10, 2023
1 parent 15ce54e commit 3ebfe8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
### Fixes
- Make the bots automatically accept group chat contact requests. #4377
- Fetch at most 100 existing messages even if EXISTS was not received. #4383
- Recreate `smtp` table with AUTOINCREMENT `id`. #4390

### Fixes
- jsonrpc: typescript client: fix types of events in event emitter
Expand Down
17 changes: 17 additions & 0 deletions src/sql/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,23 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
)
.await?;
}
if dbversion < 101 {
// Recreate `smtp` table without `rfc724_mid` field and with autoincrement.
sql.execute_migration(
"DROP TABLE smtp;
CREATE TABLE smtp (
id INTEGER PRIMARY KEY AUTOINCREMENT,
rfc724_mid TEXT NOT NULL, -- Message-ID
mime TEXT NOT NULL, -- SMTP payload
msg_id INTEGER NOT NULL, -- ID of the message in `msgs` table
recipients TEXT NOT NULL, -- List of recipients separated by space
retries INTEGER NOT NULL DEFAULT 0 -- Number of failed attempts to send the message
);
",
101,
)
.await?;
}

let new_version = sql
.get_raw_config_int(VERSION_CFG)
Expand Down

0 comments on commit 3ebfe8e

Please sign in to comment.