{-# LANGUAGE NamedFieldPuns #-}
module Simplex.Messaging.Agent.Store.SQLite.Migrations.App (appMigrations) where
import Data.List (sortOn)
import Database.SQLite.Simple (Query (..))
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220101_initial
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220301_snd_queue_keys
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220322_notifications
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220608_v2
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220625_v2_ntf_mode
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220811_onion_hosts
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220817_connection_ntfs
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220905_commands
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20220915_connection_queues
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230110_users
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230117_fkey_indexes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230120_delete_errors
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230217_server_key_hash
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230223_files
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230320_retry_state
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230401_snd_files
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230510_files_pending_replicas_indexes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230516_encrypted_rcv_message_hashes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230531_switch_status
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230615_ratchet_sync
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230701_delivery_receipts
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230720_delete_expired_messages
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230722_indexes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230814_indexes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20230829_crypto_files
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20231222_command_created_at
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20231225_failed_work_items
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240121_message_delivery_indexes
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240124_file_redirect
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240223_connections_wait_delivery
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240225_ratchet_kem
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240417_rcv_files_approved_relays
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240624_snd_secure
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240702_servers_stats
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20240930_ntf_tokens_to_delete
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20241007_rcv_queues_last_broker_ts
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20241224_ratchet_e2e_snd_params
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20250203_msg_bodies
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20250322_short_links
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20250702_conn_invitations_remove_cascade_delete
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20251009_queue_to_subscribe
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20251010_client_notices
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20251230_strict_tables
import Simplex.Messaging.Agent.Store.SQLite.Migrations.M20260410_receive_attempts
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
schemaMigrations :: [(String, Query, Maybe Query)]
schemaMigrations :: [(String, Query, Maybe Query)]
schemaMigrations =
[ (String
"20220101_initial", Query
m20220101_initial, Maybe Query
forall a. Maybe a
Nothing),
(String
"20220301_snd_queue_keys", Query
m20220301_snd_queue_keys, Maybe Query
forall a. Maybe a
Nothing),
(String
"20220322_notifications", Query
m20220322_notifications, Maybe Query
forall a. Maybe a
Nothing),
(String
"20220607_v2", Query
m20220608_v2, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20220625_v2_ntf_mode", Query
m20220625_v2_ntf_mode, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20220811_onion_hosts", Query
m20220811_onion_hosts, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20220817_connection_ntfs", Query
m20220817_connection_ntfs, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20220905_commands", Query
m20220905_commands, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20220915_connection_queues", Query
m20220915_connection_queues, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20230110_users", Query
m20230110_users, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20230117_fkey_indexes", Query
m20230117_fkey_indexes, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20230120_delete_errors", Query
m20230120_delete_errors, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20230217_server_key_hash", Query
m20230217_server_key_hash, Maybe Query
forall a. Maybe a
Nothing),
(String
"m20230223_files", Query
m20230223_files, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230223_files),
(String
"m20230320_retry_state", Query
m20230320_retry_state, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230320_retry_state),
(String
"m20230401_snd_files", Query
m20230401_snd_files, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230401_snd_files),
(String
"m20230510_files_pending_replicas_indexes", Query
m20230510_files_pending_replicas_indexes, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230510_files_pending_replicas_indexes),
(String
"m20230516_encrypted_rcv_message_hashes", Query
m20230516_encrypted_rcv_message_hashes, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230516_encrypted_rcv_message_hashes),
(String
"m20230531_switch_status", Query
m20230531_switch_status, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230531_switch_status),
(String
"m20230615_ratchet_sync", Query
m20230615_ratchet_sync, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230615_ratchet_sync),
(String
"m20230701_delivery_receipts", Query
m20230701_delivery_receipts, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230701_delivery_receipts),
(String
"m20230720_delete_expired_messages", Query
m20230720_delete_expired_messages, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230720_delete_expired_messages),
(String
"m20230722_indexes", Query
m20230722_indexes, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230722_indexes),
(String
"m20230814_indexes", Query
m20230814_indexes, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230814_indexes),
(String
"m20230829_crypto_files", Query
m20230829_crypto_files, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20230829_crypto_files),
(String
"m20231222_command_created_at", Query
m20231222_command_created_at, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20231222_command_created_at),
(String
"m20231225_failed_work_items", Query
m20231225_failed_work_items, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20231225_failed_work_items),
(String
"m20240121_message_delivery_indexes", Query
m20240121_message_delivery_indexes, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240121_message_delivery_indexes),
(String
"m20240124_file_redirect", Query
m20240124_file_redirect, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240124_file_redirect),
(String
"m20240223_connections_wait_delivery", Query
m20240223_connections_wait_delivery, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240223_connections_wait_delivery),
(String
"m20240225_ratchet_kem", Query
m20240225_ratchet_kem, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240225_ratchet_kem),
(String
"m20240417_rcv_files_approved_relays", Query
m20240417_rcv_files_approved_relays, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240417_rcv_files_approved_relays),
(String
"m20240624_snd_secure", Query
m20240624_snd_secure, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240624_snd_secure),
(String
"m20240702_servers_stats", Query
m20240702_servers_stats, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240702_servers_stats),
(String
"m20240930_ntf_tokens_to_delete", Query
m20240930_ntf_tokens_to_delete, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20240930_ntf_tokens_to_delete),
(String
"m20241007_rcv_queues_last_broker_ts", Query
m20241007_rcv_queues_last_broker_ts, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20241007_rcv_queues_last_broker_ts),
(String
"m20241224_ratchet_e2e_snd_params", Query
m20241224_ratchet_e2e_snd_params, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20241224_ratchet_e2e_snd_params),
(String
"m20250203_msg_bodies", Query
m20250203_msg_bodies, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20250203_msg_bodies),
(String
"m20250322_short_links", Query
m20250322_short_links, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20250322_short_links),
(String
"m20250702_conn_invitations_remove_cascade_delete", Query
m20250702_conn_invitations_remove_cascade_delete, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20250702_conn_invitations_remove_cascade_delete),
(String
"m20251009_queue_to_subscribe", Query
m20251009_queue_to_subscribe, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20251009_queue_to_subscribe),
(String
"m20251010_client_notices", Query
m20251010_client_notices, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20251010_client_notices),
(String
"m20251230_strict_tables", Query
m20251230_strict_tables, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20251230_strict_tables),
(String
"m20260410_receive_attempts", Query
m20260410_receive_attempts, Query -> Maybe Query
forall a. a -> Maybe a
Just Query
down_m20260410_receive_attempts)
]
appMigrations :: [Migration]
appMigrations :: [Migration]
appMigrations = (Migration -> String) -> [Migration] -> [Migration]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn Migration -> String
name ([Migration] -> [Migration]) -> [Migration] -> [Migration]
forall a b. (a -> b) -> a -> b
$ ((String, Query, Maybe Query) -> Migration)
-> [(String, Query, Maybe Query)] -> [Migration]
forall a b. (a -> b) -> [a] -> [b]
map (String, Query, Maybe Query) -> Migration
migration [(String, Query, Maybe Query)]
schemaMigrations
where
migration :: (String, Query, Maybe Query) -> Migration
migration (String
name, Query
up, Maybe Query
down) = Migration {String
name :: String
name :: String
name, up :: Text
up = Query -> Text
fromQuery Query
up, down :: Maybe Text
down = Query -> Text
fromQuery (Query -> Text) -> Maybe Query -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Query
down}