diff --git a/simplex-chat.cabal b/simplex-chat.cabal index 7de66a5bd..2798a29f7 100644 --- a/simplex-chat.cabal +++ b/simplex-chat.cabal @@ -88,6 +88,7 @@ library Simplex.Chat.Migrations.M20230317_hidden_profiles Simplex.Chat.Migrations.M20230318_file_description Simplex.Chat.Migrations.M20230321_agent_file_deleted + Simplex.Chat.Migrations.M20230328_files_protocol Simplex.Chat.Mobile Simplex.Chat.Mobile.WebRTC Simplex.Chat.Options diff --git a/src/Simplex/Chat/Migrations/M20230328_files_protocol.hs b/src/Simplex/Chat/Migrations/M20230328_files_protocol.hs new file mode 100644 index 000000000..569037830 --- /dev/null +++ b/src/Simplex/Chat/Migrations/M20230328_files_protocol.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE QuasiQuotes #-} + +module Simplex.Chat.Migrations.M20230328_files_protocol where + +import Database.SQLite.Simple (Query) +import Database.SQLite.Simple.QQ (sql) + +m20230328_files_protocol :: Query +m20230328_files_protocol = + [sql| +ALTER TABLE files ADD COLUMN protocol TEXT NOT NULL DEFAULT 'smp'; +|] + +down_m20230328_files_protocol :: Query +down_m20230328_files_protocol = + [sql| +ALTER TABLE files DROP COLUMN protocol; +|] diff --git a/src/Simplex/Chat/Migrations/chat_schema.sql b/src/Simplex/Chat/Migrations/chat_schema.sql index ed1b30354..4fc96eb5d 100644 --- a/src/Simplex/Chat/Migrations/chat_schema.sql +++ b/src/Simplex/Chat/Migrations/chat_schema.sql @@ -200,7 +200,8 @@ CREATE TABLE files( file_inline TEXT, agent_snd_file_id BLOB NULL, private_snd_file_descr TEXT NULL, - agent_snd_file_deleted INTEGER DEFAULT 0 CHECK(agent_snd_file_deleted NOT NULL) + agent_snd_file_deleted INTEGER DEFAULT 0 CHECK(agent_snd_file_deleted NOT NULL), + protocol TEXT NOT NULL DEFAULT 'smp' ); CREATE TABLE snd_files( file_id INTEGER NOT NULL REFERENCES files ON DELETE CASCADE, diff --git a/src/Simplex/Chat/Store.hs b/src/Simplex/Chat/Store.hs index 1d45e2fe9..becdcbb45 100644 --- a/src/Simplex/Chat/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -363,6 +363,7 @@ import Simplex.Chat.Migrations.M20230303_group_link_role import Simplex.Chat.Migrations.M20230317_hidden_profiles import Simplex.Chat.Migrations.M20230318_file_description import Simplex.Chat.Migrations.M20230321_agent_file_deleted +import Simplex.Chat.Migrations.M20230328_files_protocol import Simplex.Chat.Protocol import Simplex.Chat.Types import Simplex.Chat.Util (week) @@ -432,7 +433,8 @@ schemaMigrations = ("20230303_group_link_role", m20230303_group_link_role, Nothing), ("20230317_hidden_profiles", m20230317_hidden_profiles, Just down_m20230317_hidden_profiles), ("20230318_file_description", m20230318_file_description, Just down_m20230318_file_description), - ("20230321_agent_file_deleted", m20230321_agent_file_deleted, Just down_m20230321_agent_file_deleted) + ("20230321_agent_file_deleted", m20230321_agent_file_deleted, Just down_m20230321_agent_file_deleted), + ("20230328_files_protocol", m20230328_files_protocol, Just down_m20230328_files_protocol) ] -- | The list of migrations in ascending order by date