From 6d41071da1f01678b9ab449ed7f00391067da43a Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 11 Jun 2020 00:03:30 +0200 Subject: Recreate avatar database table, fixes unique constraint --- libdino/src/service/database.vala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 841518d8..d3bc71c2 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -7,7 +7,7 @@ using Dino.Entities; namespace Dino { public class Database : Qlite.Database { - private const int VERSION = 15; + private const int VERSION = 16; public class AccountTable : Table { public Column id = new Column.Integer("id") { primary_key = true, auto_increment = true }; @@ -186,7 +186,7 @@ public class Database : Qlite.Database { internal AvatarTable(Database db) { base(db, "contact_avatar"); init({jid_id, account_id, hash, type_}); - unique({jid_id, account_id}, "REPLACE"); + unique({jid_id, account_id, type_}, "REPLACE"); } } @@ -380,6 +380,14 @@ public class Database : Qlite.Database { error("Failed to upgrade to database version 15: %s", e.message); } } + if (oldVersion < 16) { + try { + exec("DROP TABLE contact_avatar"); + avatar.create_table_at_version(VERSION); + } catch (Error e) { + error("Failed to upgrade to database version 16: %s", e.message); + } + } } public ArrayList get_accounts() { -- cgit v1.2.3-54-g00ecf