merge migrations

This commit is contained in:
Evgeny @ SimpleX Chat
2026-09-29 10:23:56 +00:00
parent 6b3695b339
commit 4a57c94075
8 changed files with 26 additions and 61 deletions
@@ -463,7 +463,7 @@ The result of each includes `directPresHeader` of the agent binding:
**6. Stored request header**
Migration `M20260924_conn_pres_header`, SQLite and Postgres:
Migration `M20260925_badge_bindings`, SQLite and Postgres, first statement; the rest is in item 11:
```sql
ALTER TABLE connections ADD COLUMN pres_header BLOB;
@@ -520,7 +520,7 @@ ALTER TABLE connections ADD COLUMN pres_header BLOB;
A member's accepted proof is stored on the membership, in `file_badge_proofs`, and forwarded in channel introductions. The badge in the profile row is kept for display.
Migration `M20260925_member_badge_proofs`, SQLite:
Migration `M20260925_badge_bindings`, after the statement of item 6, SQLite:
```sql
PRAGMA writable_schema=1;
+2 -4
View File
@@ -168,8 +168,7 @@ library
Simplex.Chat.Store.Postgres.Migrations.M20260915_user_badges
Simplex.Chat.Store.Postgres.Migrations.M20260918_badge_issue_errors
Simplex.Chat.Store.Postgres.Migrations.M20260923_preferences_json
Simplex.Chat.Store.Postgres.Migrations.M20260924_conn_pres_header
Simplex.Chat.Store.Postgres.Migrations.M20260925_member_badge_proofs
Simplex.Chat.Store.Postgres.Migrations.M20260925_badge_bindings
else
exposed-modules:
Simplex.Chat.Archive
@@ -347,8 +346,7 @@ library
Simplex.Chat.Store.SQLite.Migrations.M20260915_user_badges
Simplex.Chat.Store.SQLite.Migrations.M20260918_badge_issue_errors
Simplex.Chat.Store.SQLite.Migrations.M20260923_preferences_json
Simplex.Chat.Store.SQLite.Migrations.M20260924_conn_pres_header
Simplex.Chat.Store.SQLite.Migrations.M20260925_member_badge_proofs
Simplex.Chat.Store.SQLite.Migrations.M20260925_badge_bindings
other-modules:
Paths_simplex_chat
hs-source-dirs:
@@ -53,8 +53,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20260904_file_badges
import Simplex.Chat.Store.Postgres.Migrations.M20260915_user_badges
import Simplex.Chat.Store.Postgres.Migrations.M20260918_badge_issue_errors
import Simplex.Chat.Store.Postgres.Migrations.M20260923_preferences_json
import Simplex.Chat.Store.Postgres.Migrations.M20260924_conn_pres_header
import Simplex.Chat.Store.Postgres.Migrations.M20260925_member_badge_proofs
import Simplex.Chat.Store.Postgres.Migrations.M20260925_badge_bindings
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
schemaMigrations :: [(String, Text, Maybe Text)]
@@ -108,8 +107,7 @@ schemaMigrations =
("20260915_user_badges", m20260915_user_badges, Just down_m20260915_user_badges),
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors),
("20260923_preferences_json", m20260923_preferences_json, Just down_m20260923_preferences_json),
("20260924_conn_pres_header", m20260924_conn_pres_header, Just down_m20260924_conn_pres_header),
("20260925_member_badge_proofs", m20260925_member_badge_proofs, Just down_m20260925_member_badge_proofs)
("20260925_badge_bindings", m20260925_badge_bindings, Just down_m20260925_badge_bindings)
]
-- | The list of migrations in ascending order by date
@@ -1,19 +0,0 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.Postgres.Migrations.M20260924_conn_pres_header where
import Data.Text (Text)
import Text.RawString.QQ (r)
m20260924_conn_pres_header :: Text
m20260924_conn_pres_header =
[r|
ALTER TABLE connections ADD COLUMN pres_header BYTEA;
|]
down_m20260924_conn_pres_header :: Text
down_m20260924_conn_pres_header =
[r|
ALTER TABLE connections DROP COLUMN pres_header;
|]
@@ -1,14 +1,16 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.Postgres.Migrations.M20260925_member_badge_proofs where
module Simplex.Chat.Store.Postgres.Migrations.M20260925_badge_bindings where
import Data.Text (Text)
import Text.RawString.QQ (r)
m20260925_member_badge_proofs :: Text
m20260925_member_badge_proofs =
m20260925_badge_bindings :: Text
m20260925_badge_bindings =
[r|
ALTER TABLE connections ADD COLUMN pres_header BYTEA;
ALTER TABLE file_badge_proofs ALTER COLUMN file_id DROP NOT NULL;
ALTER TABLE file_badge_proofs ADD COLUMN group_member_id BIGINT REFERENCES group_members ON DELETE CASCADE;
@@ -16,8 +18,8 @@ ALTER TABLE file_badge_proofs ADD COLUMN group_member_id BIGINT REFERENCES group
CREATE UNIQUE INDEX idx_file_badge_proofs_group_member_id ON file_badge_proofs(group_member_id);
|]
down_m20260925_member_badge_proofs :: Text
down_m20260925_member_badge_proofs =
down_m20260925_badge_bindings :: Text
down_m20260925_badge_bindings =
[r|
DROP INDEX idx_file_badge_proofs_group_member_id;
@@ -26,4 +28,6 @@ DELETE FROM file_badge_proofs WHERE group_member_id IS NOT NULL;
ALTER TABLE file_badge_proofs DROP COLUMN group_member_id;
ALTER TABLE file_badge_proofs ALTER COLUMN file_id SET NOT NULL;
ALTER TABLE connections DROP COLUMN pres_header;
|]
+2 -4
View File
@@ -176,8 +176,7 @@ import Simplex.Chat.Store.SQLite.Migrations.M20260904_file_badges
import Simplex.Chat.Store.SQLite.Migrations.M20260915_user_badges
import Simplex.Chat.Store.SQLite.Migrations.M20260918_badge_issue_errors
import Simplex.Chat.Store.SQLite.Migrations.M20260923_preferences_json
import Simplex.Chat.Store.SQLite.Migrations.M20260924_conn_pres_header
import Simplex.Chat.Store.SQLite.Migrations.M20260925_member_badge_proofs
import Simplex.Chat.Store.SQLite.Migrations.M20260925_badge_bindings
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
schemaMigrations :: [(String, Query, Maybe Query)]
@@ -354,8 +353,7 @@ schemaMigrations =
("20260915_user_badges", m20260915_user_badges, Just down_m20260915_user_badges),
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors),
("20260923_preferences_json", m20260923_preferences_json, Just down_m20260923_preferences_json),
("20260924_conn_pres_header", m20260924_conn_pres_header, Just down_m20260924_conn_pres_header),
("20260925_member_badge_proofs", m20260925_member_badge_proofs, Just down_m20260925_member_badge_proofs)
("20260925_badge_bindings", m20260925_badge_bindings, Just down_m20260925_badge_bindings)
]
-- | The list of migrations in ascending order by date
@@ -1,18 +0,0 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.SQLite.Migrations.M20260924_conn_pres_header where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20260924_conn_pres_header :: Query
m20260924_conn_pres_header =
[sql|
ALTER TABLE connections ADD COLUMN pres_header BLOB;
|]
down_m20260924_conn_pres_header :: Query
down_m20260924_conn_pres_header =
[sql|
ALTER TABLE connections DROP COLUMN pres_header;
|]
@@ -1,13 +1,15 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.SQLite.Migrations.M20260925_member_badge_proofs where
module Simplex.Chat.Store.SQLite.Migrations.M20260925_badge_bindings where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20260925_member_badge_proofs :: Query
m20260925_member_badge_proofs =
m20260925_badge_bindings :: Query
m20260925_badge_bindings =
[sql|
ALTER TABLE connections ADD COLUMN pres_header BLOB;
PRAGMA writable_schema=1;
UPDATE sqlite_master
@@ -21,8 +23,8 @@ ALTER TABLE file_badge_proofs ADD COLUMN group_member_id INTEGER REFERENCES grou
CREATE UNIQUE INDEX idx_file_badge_proofs_group_member_id ON file_badge_proofs(group_member_id);
|]
down_m20260925_member_badge_proofs :: Query
down_m20260925_member_badge_proofs =
down_m20260925_badge_bindings :: Query
down_m20260925_badge_bindings =
[sql|
DROP INDEX idx_file_badge_proofs_group_member_id;
@@ -37,4 +39,6 @@ SET sql = replace(sql, 'file_id INTEGER REFERENCES files', 'file_id INTEGER NOT
WHERE name = 'file_badge_proofs' AND type = 'table';
PRAGMA writable_schema=RESET;
ALTER TABLE connections DROP COLUMN pres_header;
|]