mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-11 11:04:56 +00:00
core: keep chat item edit history (#2410)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Migrations.M20230505_chat_item_versions where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20230505_chat_item_versions :: Query
|
||||
m20230505_chat_item_versions =
|
||||
[sql|
|
||||
CREATE TABLE chat_item_versions ( -- contains versions only for edited chat items, including current version
|
||||
chat_item_version_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
chat_item_id INTEGER NOT NULL REFERENCES chat_items ON DELETE CASCADE,
|
||||
msg_content TEXT NOT NULL,
|
||||
item_version_ts TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX idx_chat_item_versions_chat_item_id ON chat_item_versions(chat_item_id);
|
||||
|]
|
||||
|
||||
down_m20230505_chat_item_versions :: Query
|
||||
down_m20230505_chat_item_versions =
|
||||
[sql|
|
||||
DROP INDEX idx_chat_item_versions_chat_item_id;
|
||||
|
||||
DROP TABLE chat_item_versions;
|
||||
|]
|
||||
@@ -454,6 +454,15 @@ CREATE TABLE msg_delivery_events(
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
CREATE TABLE chat_item_versions(
|
||||
-- contains versions only for edited chat items, including current version
|
||||
chat_item_version_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
chat_item_id INTEGER NOT NULL REFERENCES chat_items ON DELETE CASCADE,
|
||||
msg_content TEXT NOT NULL,
|
||||
item_version_ts TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT(datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
|
||||
);
|
||||
CREATE INDEX contact_profiles_index ON contact_profiles(
|
||||
display_name,
|
||||
full_name
|
||||
@@ -595,3 +604,6 @@ CREATE INDEX idx_extra_xftp_file_descriptions_user_id ON extra_xftp_file_descrip
|
||||
CREATE INDEX idx_xftp_file_descriptions_user_id ON xftp_file_descriptions(
|
||||
user_id
|
||||
);
|
||||
CREATE INDEX idx_chat_item_versions_chat_item_id ON chat_item_versions(
|
||||
chat_item_id
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user