do not SELECT * on old tables to fill new ones (#3842)

* do not `SELECT *` on old tables to fill new ones

the old table may contain deprecrated columns for whatever reason;
as a result the query fails as the statement tries to insert eg.
16 columns into 12 colums
(concrete error for acpeerstate that have several deprecated columns)

* update CHANGELOG
This commit is contained in:
bjoern
2022-12-13 20:12:29 +01:00
committed by GitHub
parent 2a2db4f526
commit ccd0842df8
2 changed files with 7 additions and 2 deletions

View File

@@ -637,7 +637,11 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
verified_key_fingerprint TEXT DEFAULT '',
UNIQUE (addr) -- Only one peerstate per address
);
INSERT OR IGNORE INTO new_acpeerstates SELECT * FROM acpeerstates;
INSERT OR IGNORE INTO new_acpeerstates SELECT
id, addr, last_seen, last_seen_autocrypt, public_key, prefer_encrypted,
gossip_timestamp, gossip_key, public_key_fingerprint,
gossip_key_fingerprint, verified_key, verified_key_fingerprint
FROM acpeerstates;
DROP TABLE acpeerstates;
ALTER TABLE new_acpeerstates RENAME TO acpeerstates;
CREATE INDEX acpeerstates_index1 ON acpeerstates (addr);
@@ -652,7 +656,7 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
if dbversion < 95 {
sql.execute_migration(
"CREATE TABLE new_chats_contacts (chat_id INTEGER, contact_id INTEGER, UNIQUE(chat_id, contact_id));\
INSERT OR IGNORE INTO new_chats_contacts SELECT * FROM chats_contacts;\
INSERT OR IGNORE INTO new_chats_contacts SELECT chat_id, contact_id FROM chats_contacts;\
DROP TABLE chats_contacts;\
ALTER TABLE new_chats_contacts RENAME TO chats_contacts;\
CREATE INDEX chats_contacts_index1 ON chats_contacts (chat_id);\