merged with fixes

This commit is contained in:
onysd 2026-09-09 02:49:30 +03:00
parent a9e758b712
commit 2f1818d656
176 changed files with 9000 additions and 907 deletions

View file

@ -0,0 +1,4 @@
-- No-op: see 0181_sticker_set_system_key_unique.up.sql. The real schema
-- change (and its reversal) lives in
-- 20260901000006_sticker_set_system_key_unique.down.sql.
SELECT 1;

View file

@ -0,0 +1,12 @@
-- No-op placeholder. This migration's real content (sticker_sets.system_key
-- uniqueness) already applies via 20260901000006_sticker_set_system_key_unique
-- (identical SQL, applied earlier under our fork's own timestamp-based
-- migration numbering). The version number 181 itself must still exist as a
-- migration, though: internal/store/postgres/postgres.go's Migrate() calls
-- m.Migrate(phoneIdentityPredecessorVersion) (=181) to step a fresh database
-- to exactly this version before running the Go-side phone-identity
-- canonicalization pass, and golang-migrate requires that version to be a
-- real, reachable migration file. Do not reapply the sticker_sets change here
-- -- 20260901000006 already owns it, and repeating it would fail on an
-- already-unique index for any install that runs both.
SELECT 1;

View file

@ -0,0 +1,3 @@
-- E.164 canonicalization is intentionally irreversible: the removed national
-- trunk presentation is not part of the account identity.
SELECT 1;

View file

@ -0,0 +1,5 @@
-- The country-aware data rewrite is executed transactionally by
-- postgres.canonicalizeStoredPhoneIdentities before this durable version marker.
-- Keeping it in Go avoids incorrect SQL-only stripping of significant leading
-- zeroes (for example Italian fixed-line numbers).
SELECT 1;

View file

@ -0,0 +1,8 @@
DO $$ BEGIN
IF EXISTS (SELECT 1 FROM private_messages WHERE reply_external <> '{}'::jsonb)
OR EXISTS (SELECT 1 FROM message_boxes WHERE reply_external <> '{}'::jsonb) THEN
RAISE EXCEPTION 'cannot discard durable external reply snapshots';
END IF;
END $$;
ALTER TABLE message_boxes DROP COLUMN reply_external;
ALTER TABLE private_messages DROP COLUMN reply_external;

View file

@ -0,0 +1,7 @@
ALTER TABLE private_messages ADD COLUMN reply_external jsonb NOT NULL DEFAULT '{}'::jsonb;
ALTER TABLE message_boxes ADD COLUMN reply_external jsonb NOT NULL DEFAULT '{}'::jsonb;
ALTER TABLE private_messages ADD CONSTRAINT private_messages_reply_external_object
CHECK (jsonb_typeof(reply_external) = 'object' AND octet_length(reply_external::text) <= 1048576);
ALTER TABLE message_boxes ADD CONSTRAINT message_boxes_reply_external_object
CHECK (jsonb_typeof(reply_external) = 'object' AND octet_length(reply_external::text) <= 1048576);