SQLite stores self-referencing FK identifiers with quotes (REFERENCES "dm_messages"), but the migration guard only checked for the unquoted string. This caused the migration to re-run on every server startup, which DROP TABLE dm_messages and triggered ON DELETE CASCADE on attachments.dm_message_id — wiping every DM-linked attachment.