mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-01 20:08:57 +00:00
core: fix deleting user with chat tags (#6374)
* core: fix deleting user with chat tags * schema, tests * schema * update simplexmq * update ios * plans
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.SQLite.Migrations.M20251017_chat_tags_cascade where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20251017_chat_tags_cascade :: Query
|
||||
m20251017_chat_tags_cascade =
|
||||
[sql|
|
||||
PRAGMA writable_schema=1;
|
||||
|
||||
UPDATE sqlite_master
|
||||
SET sql = replace(sql, 'user_id INTEGER REFERENCES users', 'user_id INTEGER REFERENCES users ON DELETE CASCADE')
|
||||
WHERE name = 'chat_tags' AND type = 'table';
|
||||
|
||||
PRAGMA writable_schema=0;
|
||||
|]
|
||||
|
||||
down_m20251017_chat_tags_cascade :: Query
|
||||
down_m20251017_chat_tags_cascade =
|
||||
[sql|
|
||||
PRAGMA writable_schema=1;
|
||||
|
||||
UPDATE sqlite_master
|
||||
SET sql = replace(sql, 'user_id INTEGER REFERENCES users ON DELETE CASCADE', 'user_id INTEGER REFERENCES users')
|
||||
WHERE name = 'chat_tags' AND type = 'table';
|
||||
|
||||
PRAGMA writable_schema=0;
|
||||
|]
|
||||
@@ -3329,6 +3329,16 @@ Query:
|
||||
Plan:
|
||||
SEARCH chat_item_versions USING INDEX idx_chat_item_versions_chat_item_id (chat_item_id=?)
|
||||
|
||||
Query:
|
||||
SELECT chat_tag_id, chat_tag_emoji, chat_tag_text
|
||||
FROM chat_tags
|
||||
WHERE user_id = ?
|
||||
ORDER BY tag_order
|
||||
|
||||
Plan:
|
||||
SEARCH chat_tags USING INDEX idx_chat_tags_user_id (user_id=?)
|
||||
USE TEMP B-TREE FOR ORDER BY
|
||||
|
||||
Query:
|
||||
SELECT command_id, connection_id, command_function, command_status
|
||||
FROM commands
|
||||
@@ -4333,6 +4343,20 @@ Query:
|
||||
|
||||
Plan:
|
||||
|
||||
Query:
|
||||
INSERT INTO chat_tags (user_id, chat_tag_emoji, chat_tag_text, tag_order)
|
||||
VALUES (?,?,?, COALESCE((SELECT MAX(tag_order) + 1 FROM chat_tags WHERE user_id = ?), 1))
|
||||
|
||||
Plan:
|
||||
SCALAR SUBQUERY 1
|
||||
SEARCH chat_tags USING INDEX idx_chat_tags_user_id (user_id=?)
|
||||
|
||||
Query:
|
||||
INSERT INTO chat_tags_chats (contact_id, chat_tag_id)
|
||||
VALUES (?,?)
|
||||
|
||||
Plan:
|
||||
|
||||
Query:
|
||||
INSERT INTO commands (connection_id, command_function, command_status, user_id, created_at, updated_at)
|
||||
VALUES (?,?,?,?,?,?)
|
||||
|
||||
@@ -663,7 +663,7 @@ CREATE TABLE operator_usage_conditions(
|
||||
);
|
||||
CREATE TABLE chat_tags(
|
||||
chat_tag_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER REFERENCES users,
|
||||
user_id INTEGER REFERENCES users ON DELETE CASCADE,
|
||||
chat_tag_text TEXT NOT NULL,
|
||||
chat_tag_emoji TEXT,
|
||||
tag_order INTEGER NOT NULL
|
||||
|
||||
Reference in New Issue
Block a user