Files
status-go/internal/protocol/migrations/sqlite/1632303896_modify_contacts_table.up.sql
Igor Sirotin f3e4363808 refactor: move protocol to internal/protocol
Part of the Go project layout migration, item 27.

Pure move plus import-path rewrite across 502 files. No API or behaviour
change. `internal/` keeps the messaging application logic unimportable
from outside the module, which is what the issue asks for -- status-go is
consumed through the C-bindings in mobile/, not as a Go library.

Things that had to follow the move, beyond the Go imports:

- tools/generate-handlers/template.txt. messenger_handlers.go is
  generated, and the template hard-codes the imports it emits, so the
  generated file kept importing protocol/common and failed typecheck.
- .gitignore. The ignore rule for that generated file was pinned to the
  old path; without moving it, a 1486-line generated file starts being
  tracked.
- Makefile: the logosstorage and torrent test targets (both the archive
  packages and ./protocol itself), the archive README, migration-protocol.
- scripts/run_unit_tests.sh, which names the protocol package explicitly
  to shard its tests.
- scripts/cleanup_generated_files.sh and .golangci.yml.

scripts/migration_check.sh also needed a fix that is not specific to this
move: it validated every file the branch touched under a migration dir
against the timestamp naming rule, and a directory rename makes every
migration in it look newly added. It now excludes renames, so moving a
migration is not mistaken for adding one.

refs #7067
2026-08-21 10:11:05 +02:00

36 lines
1.5 KiB
SQL

ALTER TABLE contacts ADD COLUMN added BOOLEAN DEFAULT FALSE;
ALTER TABLE contacts ADD COLUMN has_added_us BOOLEAN DEFAULT FALSE;
ALTER TABLE contacts ADD COLUMN blocked BOOLEAN DEFAULT FALSE;
CREATE INDEX tmp_contacts ON contacts(hex(system_tags));
UPDATE contacts SET added = 1 WHERE hex(system_tags) LIKE '%6164646564%';
UPDATE contacts SET has_added_us = 1 WHERE hex(system_tags) LIKE '%72656365%';
UPDATE contacts SET blocked = 1 WHERE hex(system_tags) LIKE '%626c6f636b6564%';
CREATE INDEX contacts_added on contacts(added);
CREATE INDEX contacts_has_added_us on contacts(has_added_us);
CREATE INDEX contacts_blocked on contacts(blocked);
CREATE INDEX contacts_local_nickname on contacts(local_nickname);
CREATE INDEX tmp_contacts_delete ON contacts(added, blocked, local_nickname);
DELETE FROM contacts
WHERE NOT(added) AND NOT(blocked) AND NOT(has_added_us) AND (local_nickname == "" OR local_nickname IS NULL)
AND NOT EXISTS (SELECT 1 FROM chat_identity_contacts i WHERE id = i.contact_id)
AND NOT EXISTS (SELECT 1 FROM ens_verification_records v WHERE id = v.public_key);
/*
would be cool to remove these columns
ALTER TABLE contacts DROP COLUMN name;
ALTER TABLE contacts DROP COLUMN ens_verified;
ALTER TABLE contacts DROP COLUMN ens_verified_at;
ALTER TABLE contacts DROP COLUMN device_info;
ALTER TABLE contacts DROP COLUMN system_tags;
ALTER TABLE contacts DROP COLUMN tribute_to_talk;
ALTER TABLE contacts DROP COLUMN last_ens_clock_value;
ALTER TABLE contacts DROP COLUMN photo;
*/
DROP INDEX tmp_contacts_delete;
DROP INDEX tmp_contacts;