mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-03 02:30:19 +00:00
core: add down migrations and fix test
This commit is contained in:
@@ -37,3 +37,20 @@ CREATE INDEX idx_rcv_files_file_descr_id ON rcv_files(file_descr_id);
|
||||
|
||||
ALTER TABLE rcv_files ADD COLUMN agent_rcv_file_id BLOB NULL;
|
||||
|]
|
||||
|
||||
down_m20230318_file_description :: Query
|
||||
down_m20230318_file_description =
|
||||
[sql|
|
||||
ALTER TABLE rcv_files DROP COLUMN agent_rcv_file_id;
|
||||
|
||||
DROP INDEX idx_rcv_files_file_descr_id;
|
||||
ALTER TABLE rcv_files DROP COLUMN file_descr_id;
|
||||
|
||||
DROP INDEX idx_snd_files_file_descr_id;
|
||||
ALTER TABLE snd_files DROP COLUMN file_descr_id;
|
||||
|
||||
ALTER TABLE files DROP COLUMN private_snd_file_descr;
|
||||
ALTER TABLE files DROP COLUMN agent_snd_file_id;
|
||||
|
||||
DROP TABLE xftp_file_descriptions;
|
||||
|]
|
||||
|
||||
@@ -18,3 +18,11 @@ UPDATE rcv_files SET agent_rcv_file_deleted = 0;
|
||||
|
||||
PRAGMA ignore_check_constraints=OFF;
|
||||
|]
|
||||
|
||||
down_m20230321_agent_file_deleted :: Query
|
||||
down_m20230321_agent_file_deleted =
|
||||
[sql|
|
||||
ALTER TABLE rcv_files DROP COLUMN agent_rcv_file_deleted;
|
||||
|
||||
ALTER TABLE files DROP COLUMN agent_snd_file_deleted;
|
||||
|]
|
||||
|
||||
@@ -431,8 +431,8 @@ schemaMigrations =
|
||||
("20230206_item_deleted_by_group_member_id", m20230206_item_deleted_by_group_member_id, Nothing),
|
||||
("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, Nothing),
|
||||
("20230321_agent_file_deleted", m20230321_agent_file_deleted, Nothing)
|
||||
("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)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import qualified Simplex.Chat.Store as Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite (MigrationConfirmation (..), closeSQLiteStore, createSQLiteStore, withConnection)
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Migrations (Migration (..), MigrationsToRun (..), toDownMigration)
|
||||
import qualified Simplex.Messaging.Agent.Store.SQLite.Migrations as Migrations
|
||||
import Simplex.Messaging.Util (ifM)
|
||||
import Simplex.Messaging.Util (ifM, whenM)
|
||||
import System.Directory (doesFileExist, removeFile)
|
||||
import System.Process (readCreateProcess, shell)
|
||||
import Test.Hspec
|
||||
@@ -47,7 +47,7 @@ testSchemaMigrations = withTmpFiles $ do
|
||||
mapM_ (testDownMigration st) $ drop (length noDownMigrations) Store.migrations
|
||||
closeSQLiteStore st
|
||||
removeFile testDB
|
||||
removeFile testSchema
|
||||
whenM (doesFileExist testSchema) $ removeFile testSchema
|
||||
where
|
||||
testDownMigration st m = do
|
||||
putStrLn $ "down migration " <> name m
|
||||
|
||||
Reference in New Issue
Block a user