mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core: mark group contacts as used on send, receive, api (#1253)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Migrations.M20221024_contact_used where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20221024_contact_used :: Query
|
||||
m20221024_contact_used =
|
||||
[sql|
|
||||
PRAGMA ignore_check_constraints=ON;
|
||||
|
||||
ALTER TABLE contacts ADD COLUMN contact_used INTEGER DEFAULT 0 CHECK (contact_used NOT NULL);
|
||||
|
||||
UPDATE contacts SET contact_used = 0;
|
||||
|
||||
UPDATE contacts SET contact_used = 1 WHERE contact_id IN (
|
||||
SELECT DISTINCT contact_id FROM chat_items WHERE contact_id IS NOT NULL
|
||||
);
|
||||
|
||||
PRAGMA ignore_check_constraints=OFF;
|
||||
|]
|
||||
@@ -57,6 +57,7 @@ is_user INTEGER NOT NULL DEFAULT 0, -- 1 if this contact is a user
|
||||
xcontact_id BLOB,
|
||||
enable_ntfs INTEGER,
|
||||
unread_chat INTEGER DEFAULT 0 CHECK(unread_chat NOT NULL),
|
||||
contact_used INTEGER DEFAULT 0 CHECK(contact_used NOT NULL),
|
||||
FOREIGN KEY(user_id, local_display_name)
|
||||
REFERENCES display_names(user_id, local_display_name)
|
||||
ON DELETE CASCADE
|
||||
|
||||
Reference in New Issue
Block a user