diff --git a/src/Simplex/Chat/Store/Postgres/Migrations/M20260926_link_notices.hs b/src/Simplex/Chat/Store/Postgres/Migrations/M20260926_link_notices.hs new file mode 100644 index 0000000000..8590bc5261 --- /dev/null +++ b/src/Simplex/Chat/Store/Postgres/Migrations/M20260926_link_notices.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} + +module Simplex.Chat.Store.Postgres.Migrations.M20260926_link_notices where + +import Data.Text (Text) +import Text.RawString.QQ (r) + +m20260926_link_notices :: Text +m20260926_link_notices = + [r| +CREATE TABLE link_notices( + link_notice_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + link_hash BYTEA NOT NULL, + expires_at TIMESTAMPTZ, + reason TEXT, + created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL +); + +CREATE UNIQUE INDEX idx_link_notices_link_hash ON link_notices(link_hash); +|] + +down_m20260926_link_notices :: Text +down_m20260926_link_notices = + [r| +DROP INDEX idx_link_notices_link_hash; +DROP TABLE link_notices; +|] diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/M20260926_link_notices.hs b/src/Simplex/Chat/Store/SQLite/Migrations/M20260926_link_notices.hs new file mode 100644 index 0000000000..17fdc6b0e9 --- /dev/null +++ b/src/Simplex/Chat/Store/SQLite/Migrations/M20260926_link_notices.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE QuasiQuotes #-} + +module Simplex.Chat.Store.SQLite.Migrations.M20260926_link_notices where + +import Database.SQLite.Simple (Query) +import Database.SQLite.Simple.QQ (sql) + +m20260926_link_notices :: Query +m20260926_link_notices = + [sql| +CREATE TABLE link_notices( + link_notice_id INTEGER PRIMARY KEY AUTOINCREMENT, + link_hash BLOB NOT NULL, + expires_at TEXT, + reason TEXT, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL +) STRICT; + +CREATE UNIQUE INDEX idx_link_notices_link_hash ON link_notices(link_hash); +|] + +down_m20260926_link_notices :: Query +down_m20260926_link_notices = + [sql| +DROP INDEX idx_link_notices_link_hash; +DROP TABLE link_notices; +|]