core: use strict tables (#6535)

* core: use strict tables

* fix field types

* change encodings to match schema types; migrate sqlite tables to strict mode

* stabilize postgres client tests, remove slow handshake tests

* update simplexmq

* fix test

* change call_state type to text

* fix directory service queries

* update local_alias for existing schemas

* change types before strict
This commit is contained in:
Evgeny
2026-01-05 08:53:26 +00:00
committed by GitHub
parent f0467aee00
commit 87e8a10f1e
19 changed files with 220 additions and 121 deletions
@@ -0,0 +1,26 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.Postgres.Migrations.M20251230_strict_tables where
import Data.Text (Text)
import Text.RawString.QQ (r)
import Simplex.Messaging.Agent.Store.Postgres.Migrations.M20251230_strict_tables (isValidText)
m20251230_strict_tables :: Text
m20251230_strict_tables =
isValidText
<> [r|
DELETE FROM calls
WHERE NOT simplex_is_valid_text(call_state);
ALTER TABLE calls ALTER COLUMN call_state TYPE TEXT USING call_state::TEXT;
DROP FUNCTION simplex_is_valid_text(BYTEA);
|]
down_m20251230_strict_tables :: Text
down_m20251230_strict_tables =
[r|
ALTER TABLE calls ALTER COLUMN call_state TYPE BYTEA USING call_state::BYTEA;
|]
@@ -173,7 +173,7 @@ CREATE TABLE test_chat_schema.calls (
contact_id bigint NOT NULL,
shared_call_id bytea NOT NULL,
chat_item_id bigint NOT NULL,
call_state bytea NOT NULL,
call_state text NOT NULL,
call_ts timestamp with time zone NOT NULL,
user_id bigint NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,