unite migrations

This commit is contained in:
spaced4ndy 2023-12-22 11:09:33 +04:00
parent b26b03c922
commit 0be7a3117a
5 changed files with 13 additions and 30 deletions

View File

@ -127,8 +127,7 @@ library
Simplex.Chat.Migrations.M20231114_remote_control
Simplex.Chat.Migrations.M20231126_remote_ctrl_address
Simplex.Chat.Migrations.M20231207_chat_list_pagination
Simplex.Chat.Migrations.M20231214_item_content_tag
Simplex.Chat.Migrations.M20231215_recreate_msg_deliveries
Simplex.Chat.Migrations.M20231215_group_history
Simplex.Chat.Mobile
Simplex.Chat.Mobile.File
Simplex.Chat.Mobile.Shared

View File

@ -1,18 +0,0 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Migrations.M20231214_item_content_tag where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20231214_item_content_tag :: Query
m20231214_item_content_tag =
[sql|
ALTER TABLE chat_items ADD COLUMN item_content_tag TEXT;
|]
down_m20231214_item_content_tag :: Query
down_m20231214_item_content_tag =
[sql|
ALTER TABLE chat_items DROP COLUMN item_content_tag;
|]

View File

@ -1,13 +1,15 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Migrations.M20231215_recreate_msg_deliveries where
module Simplex.Chat.Migrations.M20231215_group_history where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20231215_recreate_msg_deliveries :: Query
m20231215_recreate_msg_deliveries =
m20231215_group_history :: Query
m20231215_group_history =
[sql|
ALTER TABLE chat_items ADD COLUMN item_content_tag TEXT;
DROP INDEX msg_delivery_events_msg_delivery_id;
DROP TABLE msg_delivery_events;
@ -42,8 +44,8 @@ CREATE INDEX idx_msg_deliveries_agent_msg_id ON "msg_deliveries"(connection_id,
|]
-- msg_deliveries are not repopulated on down migration, as it may cause constraint violations
down_m20231215_recreate_msg_deliveries :: Query
down_m20231215_recreate_msg_deliveries =
down_m20231215_group_history :: Query
down_m20231215_group_history =
[sql|
DROP INDEX idx_msg_deliveries_message_id;
DROP INDEX idx_msg_deliveries_agent_ack_cmd_id;
@ -76,4 +78,6 @@ CREATE TABLE msg_delivery_events (
UNIQUE (msg_delivery_id, delivery_status)
);
CREATE INDEX msg_delivery_events_msg_delivery_id ON msg_delivery_events(msg_delivery_id);
ALTER TABLE chat_items DROP COLUMN item_content_tag;
|]

View File

@ -92,8 +92,7 @@ import Simplex.Chat.Migrations.M20231113_group_forward
import Simplex.Chat.Migrations.M20231114_remote_control
import Simplex.Chat.Migrations.M20231126_remote_ctrl_address
import Simplex.Chat.Migrations.M20231207_chat_list_pagination
import Simplex.Chat.Migrations.M20231214_item_content_tag
import Simplex.Chat.Migrations.M20231215_recreate_msg_deliveries
import Simplex.Chat.Migrations.M20231215_group_history
import Simplex.Messaging.Agent.Store.SQLite.Migrations (Migration (..))
schemaMigrations :: [(String, Query, Maybe Query)]
@ -186,8 +185,7 @@ schemaMigrations =
("20231114_remote_control", m20231114_remote_control, Just down_m20231114_remote_control),
("20231126_remote_ctrl_address", m20231126_remote_ctrl_address, Just down_m20231126_remote_ctrl_address),
("20231207_chat_list_pagination", m20231207_chat_list_pagination, Just down_m20231207_chat_list_pagination),
("20231214_item_content_tag", m20231214_item_content_tag, Just down_m20231214_item_content_tag),
("20231215_recreate_msg_deliveries", m20231215_recreate_msg_deliveries, Just down_m20231215_recreate_msg_deliveries)
("20231215_group_history", m20231215_group_history, Just down_m20231215_group_history)
]
-- | The list of migrations in ascending order by date

View File

@ -75,7 +75,7 @@ skipComparisonForDownMigrations =
-- on down migration idx_connections_via_contact_uri_hash index moves down to the end of the file
"20231019_indexes",
-- table and indexes move down to the end of the file
"20231215_recreate_msg_deliveries"
"20231215_group_history"
]
getSchema :: FilePath -> FilePath -> IO String